Hey, I´m trying to rename some string values ( that contain specific parts) to another strings. Tried in the starwars tibble (dyplr). I want to rename many of them differently.
.*Na is for Naboo .*oo is for Tatooine df_test1 <- starwars %>% mutate(new_homeworld = gsub ("[.*Na.* | .*oo.*]", "A" ,homeworld) df_test1 It did not work Also tried df_test2 <- starwars %>% mutate(new_homeworld = case_when(homeworld == ".*Na.*" ~ "A", homeworld == ".*oo.*" ~ "B", TRUE ~ "C"))
Just get " C" for all values
Any thoughts on that?