I have this column in a df:
Column1 |
---|
very sunny day today |
it was sunny |
not very sunny today |
desired output
Column1 |
---|
sunny |
sunny |
not sunny |
df<-df%>%
mutate(column_1=case_when(
str_detect(column_1,"very sunny")~ "sunny",
str_detect(column_1,"sunny")~ "sunny",
str_detect(column_1,"not"&"sunny")~ " not sunny",
)
)
The code works well for the two first rows where we have more simple conditions for the 3rd row the conditions are more complicated and gives me an error.
I want to identify some keywords in that string which they are not together (very sunny) but they are separate (not very sunny today) and put them as conditions to give the desired output. Maybe I am doing something wrong with syntax.