in dplyr , na_if
can transfer value to NA, but when I want to change 0
or 1
to NA failed . How fix it ?
library(dplyr)
x <- c(1, -1, 0, 10)
this is ok
na_if(x,0)
but below code show Can't recycle y (size 2) to size 4.
I am wondering 0 and c(0,1) are not size 4 , but na_if(x,0) can work.
na_if(x,c(0,1))