Skip to content

Instantly share code, notes, and snippets.

@sjessa
Last active July 6, 2018 20:09
Show Gist options
  • Save sjessa/842cdc4b9d07669fd8b2fd054970d514 to your computer and use it in GitHub Desktop.
Save sjessa/842cdc4b9d07669fd8b2fd054970d514 to your computer and use it in GitHub Desktop.
Filter a data frame based on a set of expressions
# Filters
library(tidyverse)
sample_filters <- quos(project %in% c("dev", species %in% c("mouse")))
sample_list <- data.frame(
project = c("dev", "pbt"),
species = c("mouse", "human"),
dont_filter = c("a", "b"))
sample_list %>% filter(!!! sample_filters)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment