Skip to content

Instantly share code, notes, and snippets.

@ijlyttle
Last active November 18, 2018 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ijlyttle/958d6a06c830d13b02f86416e17ea12d to your computer and use it in GitHub Desktop.
Save ijlyttle/958d6a06c830d13b02f86416e17ea12d to your computer and use it in GitHub Desktop.
library("rlang")
library("dplyr")
library("purrr")
myfil <- function(data, names, vals) {
exprs <- purrr::map2(names, vals, ~ quo(!!sym(.x) == !!.y))
print(quo(dplyr::filter(data, !!!exprs)))
data <- dplyr::filter(data, !!!exprs)
data
}
names <- c("gear", "cyl", "carb")
vals <- c(4, 6, 4)
myfil(mtcars, names, vals)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment