I have a dataset where I have a variable called screen12m which is a 1,0 binary variable.
I want to change some of these zeros to NAs based on a condition from another variable which is called offset. So if offset variable value is < 1, I would like these zeros to be recoded into nas.
I tried:
data6 <- data5 %>%
mutate(screen12m = recode_if(screen12m, offset < 1 , "0" = NA))
However that doesn't work.
Any ideas/suggestions?
Thanks in advance!