I'm trying to hand over a filter with multiple arguments as a string to dplyr::filter within a function. The answers I've seen so far all concern single filter argument, not multiple ones.
Example:
myfil <- function(df, fil) {
quo_fil <- enquo(fil)
df <- filter(df, !! quo_fil)
df
}
set.seed(25)
df <- data.frame(a = sample(10, 10), b = sample(10, 10), c = sample(10, 10))
#works
filter(df, a > 3 & b > 2 & c < 8)
a b c
1 5 4 1
2 7 10 5
3 9 5 2
4 6 6 3
# does not work
f <- "a > 3 & b > 2 & c < 8"
myfil(df, f)