Hello,
I have a problem with dplyr and case_when using !is.na.
If I run this
data<-data %>%
mutate(tax=case_when(z13!=NA ~0
,zone==1 & z13 %in% 2:5 ~100
,zone==2 & z13 %in% 3:5 ~100))
I transform the data correctly. However, when I tried this
data<-data %>%
mutate(tax=case_when(!is.na(z13)~0
,zone==1 & z13 %in% 2:5 ~100
,zone==2 & z13 %in% 3:5 ~100))
Everything was applied as zero. I mean, all values were zeros on "tax".
The data on "z13" is integer type. I can run the code, but I think the correct way is always use is.na or !is.na
Can you guide me what am I doing wrong on the second code chunk?
Thanks for your help and time.
Have a nice weekend.