I would like to parameterize the filter function of dplyr. For e.g Instead of
mtcars %>% filter(mpg <20)
I would like a function where I can pass the column index so that I can do
a <- c(4,6)
df <- mtcars %>% filter(cyl %in% a) #- This works
But
df <- mtcars %>% filter_("cyl %in% a") #Gives 'a' not found
and
df <- mtcars %>% filter_("cyl %in% 'a'") # gives 0 rows
I will be using a variable where I am using "cyl". What am I missing?