Title: | Creating Tables of Excluded Observations |
---|---|
Description: | Instead of counting observations before and after a subset() call, the ExclusionTable() function reports the number before and after each subset() call together with the number of observations that have been excluded. This is especially useful in observational studies for keeping track how many observations have been excluded for each in-/ or exclusion criteria. You just need to provide ExclusionTable() with a dataset and a list of logical filter statements. |
Authors: | Joshua P. Entrop [aut, cre] , Simon Steiger [ctb] |
Maintainer: | Joshua P. Entrop <[email protected]> |
License: | CC BY 4.0 |
Version: | 1.1.0.9000 |
Built: | 2024-11-09 05:08:28 UTC |
Source: | https://github.com/entjos/exclusiontable |
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}
.
exclusion_table( data = NULL, inclusion_criteria = NULL, exclusion_criteria = NULL, labels_inclusion = inclusion_criteria, labels_exclusion = exclusion_criteria, obj = NULL, keep_data = TRUE, id = NULL )
exclusion_table( data = NULL, inclusion_criteria = NULL, exclusion_criteria = NULL, labels_inclusion = inclusion_criteria, labels_exclusion = exclusion_criteria, obj = NULL, keep_data = TRUE, id = NULL )
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 |
id |
Optional name of a unique ID variable in the dataset. |
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 |
If id
is supplied, an additional column is added to table_in
and
table_ex
including a list of the ids that have been excluded from
the dataset in each step.
#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) )
#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) )
exl_tbl
objectsThis is a print function for exl_tbl
objects, created with
exlcusion_table()
. The function improves the readability of the output.
## S3 method for class 'exl_tbl' print(x, ...)
## S3 method for class 'exl_tbl' print(x, ...)
x |
An |
... |
Other arguments that should be passed to print. |
No return value, called for side effects.