I am trying to use the function na_if from the package dplyr in order to replace a certain value with NAs from data frame. For example:
> nyc_ci <- data.frame(nyc_ci_lower, nyc_ci_upper) # Creating a data frame with 2 variables
> dput(nyc_ci[1:10,])
structure(list(nyc_ci_lower = c(0.126589039921449, 0.126589039921449,
0.126589039921449, 0.126589039921449, 0.126589039921449,
0.126589039921449, 0.126589039921449, 0.126589039921449,
0.126589039921449, 0.126589039921449), nyc_ci_upper =
c(18.4443972705697, 18.4443972705697, 18.4443972705697,
18.4443972705697, 18.4443972705697, 18.4443972705697,
18.4443972705697, 18.4443972705697, 18.4443972705697,
18.4443972705697)), row.names = c(NA, 10L), class = "data.frame")
> nyc_ci_lower_na <- na_if(nyc_ci$nyc_ci_lower, 0.126589039921449) # Attempting to replace 0.126589039921449 with NA
> dput(nyc_ci_lower_na[1:10])
c(0.126589039921449, 0.126589039921449, 0.126589039921449,
0.126589039921449, 0.126589039921449, 0.126589039921449,
0.126589039921449, 0.126589039921449, 0.126589039921449,
0.126589039921449)
However, when I do this, the value in question does not get replaced by NAs. I did this once before with a column from another data frame and it worked fine. Is there anything I should do differently?