Я пытаюсь скрыть команды НФЛ с соответствующим городом. При попытке case_when я получаю NA. Ниже приведен код
nfl_RM %>%
select(team_name) %>%
mutate(state = case_when(
team_name %in% c("Rams","Chargers","49ers","Raiders") ~ "California",
team_name %in% c("Jaguars", "Dolphins", "Buccaneers") ~ "Florida",
team_name %in% c("Ravens","Redskins") ~ "Maryland",
team_name == "Cardinals" ~ "Arizona",
team_name %in% c("Eagles","Steelers") ~ "Pennsylvania",
team_name %in% c("Bengals","Browns") ~ "Georgia",
team_name %in% c("Jets","Giants") ~ "New Jersey",
team_name %in% c("Cowboys","Texans") ~ "Texas",
team_name == "Broncos" ~ "Colorado",
team_name == "Falcons" ~ "Georgia",
team_name == "Bears" ~ "Illinois",
team_name == "Colts" ~ "Indiana",
team_name == "Saints" ~ "Louisiana",
team_name == "Patriots" ~ "Massachusetts",
team_name == "Lions" ~ "Michigan",
team_name == "Vikings" ~ "Minnesota",
team_name == "Chiefs" ~ "Missouri",
team_name == "Bills" ~ "New York",
team_name == "North Carolina" ~ "Panthers",
team_name == "Titans" ~ "Tennessee",
team_name == "Seahawks" ~ "Washington",
team_name == "Packers" ~ "Wisconsin"
)
)
Выход
team_name state
"Lions" NA
"Lions" NA
"Lions" NA
"Lions" NA
"Lions" NA
"Packers" NA
Кроме того, есть ли другой способ сделать это?