Hi,
I am trying to replace a bunch of words in a variable and thought of using case_when. But it doesn't seem to work right for me. Can someone help me out here, please? Example with just two words replacement,
First attempt -
df <- df%>%
mutate(Country = case_when(
"US" ~ "USA",
"CAN" ~ "Canada",
TRUE ~ ""))
Second attempt -
df <- df%>%
mutate(Country = case_when(
Country == "US" ~ "USA",
Country == "CAN" ~ "Canada"))
I get this error in both the cases
Thanks!