I am having some silly problem using lazy evaluation and dplyr.
I'm trying to filter some NA
s and don't know why the lazyeval version doesn't work. Probably I'm missing something, but I can't find it. Is that so, or is it a bug?
Here is a minimum reproducible example:
library(dplyr)
library(lazyeval)
data(iris)
iris$t <- c(1:140, rep(NA, 10))
#This Works
temp <- filter(iris, !is.na(t))
#This doesn't
temp <- filter_(iris, interp(~(!is.na(x)), x="t"))
Both codes run without throwing out an error.
You need to pass
"t"
as a name.As your code stands, you are inserting
"t"
intois.na()
to makeis.na("t")
, which is FALSE every time. And negating that gives TRUE every time, hence all rows.