I would like to be able to define arguments for dplyr
verbs
condition <- \"dist > 50\"
and then use these strings in
While they're working on that, here is a workaround using if
:
library(dplyr)
library(magrittr)
ds <- data.frame(attend = c(1:5,NA,7:9,NA,NA,12))
filter_na <- FALSE
filtertest <- function(x,filterTF = filter_na){
if(filterTF) x else !(x)
}
ds %>%
filter(attend %>% is.na %>% filtertest)
attend
1 1
2 2
3 3
4 4
5 5
6 7
7 8
8 9
9 12
filter_na <- TRUE
ds %>%
filter(attend %>% is.na %>% filtertest)
attend
1 NA
2 NA
3 NA