This function is a wrapper around dplyr::filter. Additional actions are performed on the background to log the information of the filter action, and info regarding the step is printed.
Arguments
- .data
the data frame for which the filter should be created
- ...
arguments passed to dplyr::filter
- comment
character with the reason of filtering used in log file
Details
The function can be used to keep track of records that are omitted in the data management process. In general one would like to keep all records from the source database (and use flags instead to exclude data) but in cases where this is not possible it is important to know what records are omitted and for which reason. Every time the function is used it creates a records in in a log file which can be used in the documentation.
Examples
# For full trace-ability of source data, no pipes
# are preferred
dat1 <- filterr(Theoph,Subject==1)
#> ℹ Filter applied with 121 record(s) deleted
dat2 <- Theoph |> filterr(Subject==2)
#> ℹ Filter applied with 121 record(s) deleted
# Show what is being logged
get_log()$filterr_nfo
#> datain coding datainrows dataoutrows rowsdropped comment
#> 1 Theoph Subject == 1 132 11 121
#> 2 Theoph Subject == 2 132 11 121
