(Edit: I'm undeleting this based on the comment that, when pulling from SQL, you have to use the filter_
function or it breaks. That's a separate issue and perhaps a bug in your code, but perhaps this work-around let's you get done what you need. @alistaire's comment works better, but if you need to choose a column dynamically like I initially mis-inferred, then you'll need something like this. Lacking that, this is not an answer so much as an expansion.)
As shown here: https://stackoverflow.com/a/26509961/3358272, instead using %in%
:
cn <- "Species"
fl <- c("virginica", "setosa")
filt <- lazyeval::interp(~ col %in% fl, col = as.name(cn))
tbl_df(iris) %>% filter_(filt)
# Source: local data frame [100 x 5]
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# <dbl> <dbl> <dbl> <dbl> <fctr>
# 1 5.1 3.5 1.4 0.2 setosa
# 2 4.9 3.0 1.4 0.2 setosa
# 3 4.7 3.2 1.3 0.2 setosa
# 4 4.6 3.1 1.5 0.2 setosa
# 5 5.0 3.6 1.4 0.2 setosa
# .. ... ... ... ... ...