filter_with_lists.Rd
This function filters a dataframe using a list with column and one or more values.
filter_with_lists(df, filters)
A dataframe to be filtered
A list of lists containing column names in the first element and a list their corresponding values for filtering in the second element
A dataframe filtered based on the input filters
df <- dplyr::tibble(
VIS_Groep = sample(c("Group1", "Group2", "Group3"), 100, replace = TRUE),
VIS_Groep_naam = sample(c("Name1", "Name2", "Name3"), 100, replace = TRUE),
var1 = sample(c("A", "B", "C"), 100, replace = TRUE),
var2 = rnorm(100),
color_var = sample(c("Red", "Blue", "Green"), 100, replace = TRUE)
)
filters = list(c("var1", c("A", "B")))
dfFiltered <- filter_with_lists(df, filters)