View source: R/apply_filters.R
apply_filters | R Documentation |
Apply Groups of Filter Criteria from Configuration
apply_filters(data, groups, length_column = NULL, id_columns = names(data)[1L])
data |
data frame |
groups |
names of filter criteria groups defined in list returned by
|
length_column |
name of column in |
id_columns |
names of column(s) in |
data, filtered according to the specified criteria. The returned data
frame has an attribute filter_info
being a list with as many
elements as there are groups
. The elements are named according to
the values given in groups
. Each list element is a list with one
element overview
(being a data frame with one row per filter
criterion) and further elements removed_<i>
being data frames with
only id_columns
that represent the records that have been removed in
the according filter step i
.
# Define filter criteria criteria <- list( sepal = c( "sepal short" = "Sepal.Length < 5", "sepal narrow" = "Sepal.Width < 3" ), petal = c( "petal short" = "Petal.Length < 5", "petal narrow" = "Petal.Width < 3" ) ) # Write criteria to temporary yaml file tdir <- tempdir() yaml::write_yaml(criteria, file.path(tdir, "filter_criteria.yml")) # Set path to temporary "config" folder so that kwb.prep knows about it kwb.prep:::set_user_config_dir(tdir) # Apply filter groups "sepal" and "petal" to the iris dataset result <- apply_filters(iris, c("sepal", "petal")) # Have a look at the result str(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.