exclude {healthdb} | R Documentation |
Remove rows based on conditions or another data set
Description
This function combines dplyr::anti_join()
, and negation of dplyr::filter()
. When a second data set is supplied through the excl
argument, anti join would be performed; otherwise, data
would be filtered with the expression given via the condition
argument, and the filter result would in turn be removed using dplyr::setdiff()
.
Usage
exclude(
data,
excl = NULL,
by = NULL,
condition = NULL,
verbose = getOption("healthdb.verbose"),
report_on = NULL,
...
)
Arguments
data |
Data.frames or remote tables (e.g., from |
excl |
Data frames or remote tables (e.g., from 'dbplyr'). Rows/values present in it will be removed from |
by |
Column names that should be matched by |
condition |
An expression that will be passed to |
verbose |
A logical for whether printing explanation for the operation. Default is fetching from options. Use |
report_on |
A quoted/unquoted column name for counting how many of its distinct values were removed from |
... |
Additional arguments passing to |
Value
A data frame or remote table that is a subset of data
.
Examples
# exclude with condition
cyl_not_4 <- exclude(mtcars, condition = cyl == 4, report_on = cyl)
# exclude with another data
exclude(mtcars, cyl_not_4, dplyr::join_by(cyl), report_on = cyl)