Apply Filter Criteria from List
Arguments
- data
data frame
- criteria_list
list of (named) vectors of character representing filter criteria
- element
name of list element to be selected fom
criteria_list
- length_column
passed to
applyFilterCriteria
Examples
criteria_list <- list(
apple = c("is red or green" = "colour %in% c('red', 'green')"),
banana = c("is not straight" = "! straight")
)
fruit_properties <- data.frame(
colour = c("green", "red", "yellow"),
straight = c(TRUE, TRUE, FALSE)
)
applyFilter(fruit_properties, criteria_list, "apple")
#> Evaluating colour %in% c("red", "green") ...
#> is TRUE for 2 rows ( 66.7 %),
#> FALSE for 1 rows ( 33.3 %) and
#> NA for 0 rows ( 0.0 %).
#> Selected rows now: 2
#> colour straight
#> 1 green TRUE
#> 2 red TRUE
applyFilter(fruit_properties, criteria_list, "banana")
#> Evaluating !straight ...
#> is TRUE for 1 rows ( 33.3 %),
#> FALSE for 2 rows ( 66.7 %) and
#> NA for 0 rows ( 0.0 %).
#> Selected rows now: 1
#> colour straight
#> 3 yellow FALSE