Title: | A "Snake_case" Filter System for R |
---|---|
Description: | Enables filtering datasets by a prior specified identifiers which correspond to saved filter expressions. |
Authors: | Thomas Neitman [aut] (Original creator of the package), Joe Zhu [ctb, cre], F. Hoffmann-La Roche AG [cph, fnd] |
Maintainer: | Joe Zhu <[email protected]> |
License: | Apache License 2.0 |
Version: | 0.3.1 |
Built: | 2024-11-14 04:44:13 UTC |
Source: | https://github.com/cran/filters |
Enables filtering datasets by a prior specified identifiers which correspond to saved filter expressions.
Maintainer: Joe Zhu [email protected] [contributor]
Authors:
Thomas Neitman (Original creator of the package)
Other contributors:
F. Hoffmann-La Roche AG [copyright holder, funder]
Add a new filter definition or overwrite an existing one
add_filter( id, title, target, condition, character_only = FALSE, overwrite = FALSE )
add_filter( id, title, target, condition, character_only = FALSE, overwrite = FALSE )
id |
|
title |
|
target |
|
condition |
The filter condition |
character_only |
|
overwrite |
|
The function returns a list
of title
, target
and condition
invisibly
Thomas Neitmann (neitmant
)
add_filter( id = "CTC5", title = "Grade 5 Adverse Event", target = "ADAE", condition = AETOXGR == "5" ) add_filter( id = "CTC4", title = "Grade 4 Adverse Event", target = "ADAE", condition = "AETOXGR == '4'", character_only = TRUE ) add_filter( id = "IT", title = "ITT Population", target = "ADSL", condition = ITTFL == "Y", overwrite = TRUE ) add_filter( id = "5PER", title = "Adverse Events with a Difference of at Least 5% between Treatment Arms", target = "adae", condition = 1 == 1, overwrite = TRUE )
add_filter( id = "CTC5", title = "Grade 5 Adverse Event", target = "ADAE", condition = AETOXGR == "5" ) add_filter( id = "CTC4", title = "Grade 4 Adverse Event", target = "ADAE", condition = "AETOXGR == '4'", character_only = TRUE ) add_filter( id = "IT", title = "ITT Population", target = "ADSL", condition = ITTFL == "Y", overwrite = TRUE ) add_filter( id = "5PER", title = "Adverse Events with a Difference of at Least 5% between Treatment Arms", target = "adae", condition = 1 == 1, overwrite = TRUE )
Apply a Filter to a Dataset or List of Datasets
apply_filter(data, ...) ## Default S3 method: apply_filter(data, ...) ## S3 method for class 'data.frame' apply_filter(data, id, target = deparse(substitute(data)), verbose = TRUE, ...) ## S3 method for class 'list' apply_filter(data, id, verbose = TRUE, ...)
apply_filter(data, ...) ## Default S3 method: apply_filter(data, ...) ## S3 method for class 'data.frame' apply_filter(data, id, target = deparse(substitute(data)), verbose = TRUE, ...) ## S3 method for class 'list' apply_filter(data, id, verbose = TRUE, ...)
data |
|
... |
Not used. |
id |
|
target |
|
verbose |
|
A new data.frame
or list
of data.frame
s filtered based upon the condition defined for id
Thomas Neitmann (neitmant
)
adsl <- random.cdisc.data::cadsl adae <- random.cdisc.data::cadae datasets <- list(adsl = adsl, adae = adae) add_filter("REL", "Related AEs", "ADAE", AEREL == "Y", overwrite = TRUE) apply_filter(adsl, "SE") apply_filter(adae, "SER_REL") apply_filter(datasets, "SER_REL_SE")
adsl <- random.cdisc.data::cadsl adae <- random.cdisc.data::cadae datasets <- list(adsl = adsl, adae = adae) add_filter("REL", "Related AEs", "ADAE", AEREL == "Y", overwrite = TRUE) apply_filter(adsl, "SE") apply_filter(adae, "SER_REL") apply_filter(datasets, "SER_REL_SE")
Get a Filter Definition
get_filter(id)
get_filter(id)
id |
|
A list
with elements title
, target
and condition
Thomas Neitmann (neitmant
)
get_filter("SE") get_filter("SER") ## Filter `FOO` does not exist try(get_filter("FOO"))
get_filter("SE") get_filter("SER") ## Filter `FOO` does not exist try(get_filter("FOO"))
Get Multiple Filter Definitions
get_filters(ids)
get_filters(ids)
ids |
|
A named list
of filter definitions
Thomas Neitmann (neitmant
)
get_filters("REL_SER") get_filters("OS_IT")
get_filters("REL_SER") get_filters("OS_IT")
List all available filters
list_all_filters()
list_all_filters()
A data.frame
with columns id
, title
, target
and condition
Thomas Neitmann (neitmant
)
list_all_filters()
list_all_filters()
Load filter definitions from a yaml file
load_filters(yaml_file, overwrite = FALSE)
load_filters(yaml_file, overwrite = FALSE)
yaml_file |
|
overwrite |
|
On success, load_filters()
returns TRUE
invisibly
Thomas Neitmann (neitmant
)
filter_definitions <- system.file("filters.yaml", package = "filters") if (interactive()) file.edit(filter_definitions) load_filters(filter_definitions, overwrite = TRUE)
filter_definitions <- system.file("filters.yaml", package = "filters") if (interactive()) file.edit(filter_definitions) load_filters(filter_definitions, overwrite = TRUE)