I have a variable that I want to replace some values by NA. Here's a quick example
x <- 1:15
Let's say I want everything that is above 10 to be NAs. In other words, I want x to be something like this:
1 2 3 4 5 6 7 8 9 10 NA NA NA NA NA
Is there a way to do this with tidyverse (or what is the best way to do this)? I tried na_if but that doesn't work if the condition is a range (it seems to take only a certain value). Using case_when doesn't work either. Any thoughts? Thanks!