| Type: | Package | 
| Title: | A "Snake_case" Filter System for R | 
| Version: | 0.3.1 | 
| Description: | Enables filtering datasets by a prior specified identifiers which correspond to saved filter expressions. | 
| Imports: | magrittr, plyr, yaml | 
| Suggests: | dplyr, random.cdisc.data, testthat | 
| License: | Apache License 2.0 | 
| Encoding: | UTF-8 | 
| Language: | en-US | 
| RoxygenNote: | 7.3.1 | 
| NeedsCompilation: | no | 
| Packaged: | 2024-04-16 14:55:47 UTC; rstudio | 
| Author: | Thomas Neitman [aut] (Original creator of the package), Joe Zhu [ctb, cre], F. Hoffmann-La Roche AG [cph, fnd] | 
| Maintainer: | Joe Zhu <joe.zhu@roche.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2024-04-17 09:50:05 UTC | 
filters Package
Description
Enables filtering datasets by a prior specified identifiers which correspond to saved filter expressions.
Author(s)
Maintainer: Joe Zhu joe.zhu@roche.com [contributor]
Authors:
Thomas Neitman (Original creator of the package)
Other contributors:
F. Hoffmann-La Roche AG [copyright holder, funder]
Add a New Filter Definition
Description
Add a new filter definition or overwrite an existing one
Usage
add_filter(
  id,
  title,
  target,
  condition,
  character_only = FALSE,
  overwrite = FALSE
)
Arguments
id | 
 
  | 
title | 
 
  | 
target | 
 
  | 
condition | 
 The filter condition  | 
character_only | 
 
  | 
overwrite | 
 
  | 
Value
The function returns a list of title, target and condition
invisibly
Author(s)
Thomas Neitmann (neitmant)
Examples
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
Description
Apply a Filter to a Dataset or List of Datasets
Usage
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, ...)
Arguments
data | 
 
  | 
... | 
 Not used.  | 
id | 
 
  | 
target | 
 
  | 
verbose | 
 
  | 
Value
A new data.frame or list of data.frames filtered based upon the condition defined for id
Author(s)
Thomas Neitmann (neitmant)
Examples
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
Description
Get a Filter Definition
Usage
get_filter(id)
Arguments
id | 
 
  | 
Value
A list with elements title, target and condition
Author(s)
Thomas Neitmann (neitmant)
Examples
get_filter("SE")
get_filter("SER")
## Filter `FOO` does not exist
try(get_filter("FOO"))
Get Multiple Filter Definitions
Description
Get Multiple Filter Definitions
Usage
get_filters(ids)
Arguments
ids | 
 
  | 
Value
A named list of filter definitions
Author(s)
Thomas Neitmann (neitmant)
Examples
get_filters("REL_SER")
get_filters("OS_IT")
List All Filters
Description
List all available filters
Usage
list_all_filters()
Value
A data.frame with columns id, title, target and condition
Author(s)
Thomas Neitmann (neitmant)
Examples
list_all_filters()
Load Filter Definitions
Description
Load filter definitions from a yaml file
Usage
load_filters(yaml_file, overwrite = FALSE)
Arguments
yaml_file | 
 
  | 
overwrite | 
 
  | 
Value
On success, load_filters() returns TRUE invisibly
Author(s)
Thomas Neitmann (neitmant)
Examples
filter_definitions <- system.file("filters.yaml", package = "filters")
if (interactive()) file.edit(filter_definitions)
load_filters(filter_definitions, overwrite = TRUE)