It wasn´t mutating in the whole tibble. But I figured, it was the select function. I just removed it.
Tried two diffrent ways and they worked!
df_test4 <- starwars %>%
mutate(is_naboo_or_tatooine = str_detect(homeworld,".*Nab.*|.*too.*"),
is_stewjon_or_eriadu = str_detect(homeworld,".*Ste.*|.*Eri.*"),
new_homeworld = case_when(is_naboo_or_tatooine ~ "A",
is_stewjon_or_eriadu ~ "B",
TRUE ~ homeworld))
df_test5 <- starwars %>%
mutate(new_homeworld = case_when(str_detect(homeworld,".*Nab.*|.*too.*") ~ "A",
str_detect(homeworld,".*Ste.*|.*Eri.*") ~ "B",
TRUE ~ homeworld))
What do you think about them? You helped me a lot with the str_detect. Thanks