exclusion_table {ExclusionTable} | R Documentation |
Exclusion Table
Description
This function keeps track of how many observations you exclude by using
specific inclusion and exclusion criteria. It assumes that your criteria
are logical filter statements, i.e. statements that you would pass to
dplyr::filter()
or to {data.table}
.
Usage
exclusion_table(
data = NULL,
inclusion_criteria = NULL,
exclusion_criteria = NULL,
labels_inclusion = inclusion_criteria,
labels_exclusion = exclusion_criteria,
obj = NULL,
keep_data = TRUE
)
Arguments
data |
A dataframe on which the exclusions are to be performed. |
inclusion_criteria |
A character vector of logical expressions that are used for
inclusions. All individuals who meet these criteria will be included.
Specifically, observations for which the logical expression is |
exclusion_criteria |
A character vector of logical expressions that are used for
exclusions. All observations who meet this
criteria will be excluded. Specifically, observations for which the
logical expression is |
labels_inclusion |
An optional character vector of labels that are used to label the
steps of inclusions. The default labels are the logical expressions
passed to |
labels_exclusion |
An optional character vector of labels that are used to label the
steps of exclusions. The default labels are the logical expressions
passed to |
obj |
A named list of objects that will be passed to the filtering call.
The list can be access using |
keep_data |
A logical statement to indicate whether the new dataset without the
excluded observations should be outputted. The default is |
Value
exclusion_table
returns a exl_tbl
object which is a list of
data frames including the following information:
table_in |
a |
table_ex |
a |
dataset |
a |
Examples
#Example without using the obj argument
exclusion_table(
data = mtcars,
exclusion_criteria = c("disp <= 70 | disp >= 300",
"as.character(gear) == '4'"),
labels_exclusion = c("First exclusion",
"Second exclusion")
)
#Example using the obj argument
my_selection <- c(8, 6)
exclusion_table(
data = mtcars,
exclusion_criteria = c("cyl %in% my_selection"),
labels_exclusion = c("First exclusion"),
obj = list(my_selection = my_selection)
)