How to recode 0 values of a variable to NA based on a condition from another variable

See the FAQ: How to do a minimal reproducible example reprex for beginners; having to reverse engineering data required to test a solution deters answers.

Something like this may work:

data6 <- data5 %>% mutate(screen12m = ifelse(offset  < 1, NA,screen12m))
1 Like