library(dplyr)
library(dtrackr)
iris %>% track() %>% capture_exclusions() %>% exclude_all(
Petal.Length > 5 ~ "{.excluded} long ones",
Petal.Length < 2 ~ "{.excluded} short ones"
) %>% history()
# simultaneous evaluation of criteria:
data.frame(a = 1:10) %>%
track() %>%
exclude_all(
# These two criteria identify the same value and one item is excluded
a > 9 ~ "{.excluded} value > 9",
a == max(a) ~ "{.excluded} max value",
) %>%
status() %>%
history()
# the behaviour is equivalent to the inverse of dplyr's filter function:
data.frame(a=1:10) %>%
dplyr::filter(a <= 9, a != max(a)) %>%
nrow()
# step-wise evaluation of criteria results in a different output
data.frame(a = 1:10) %>%
track() %>%
# Performing the same exclusion sequentially results in 2 items
# being excluded as the criteria no longer identify the same
# item.
exclude_all(a > 9 ~ "{.excluded} value > 9") %>%
exclude_all(a == max(a) ~ "{.excluded} max value") %>%
status() %>%
history()
# the behaviour is equivalent to the inverse of dplyr's filter function:
data.frame(a=1:10) %>%
dplyr::filter(a <= 9) %>%
dplyr::filter(a != max(a)) %>%
nrow()
Run the code above in your browser using DataLab