| filter_spec {teal.transform} | R Documentation |
Data extract filter specification
Description
It consists in choices and additionally the variable names for the choices.
Usage
filter_spec(
vars,
choices = NULL,
selected = if (inherits(choices, "delayed_data")) NULL else choices[1],
multiple = length(selected) > 1 || inherits(selected, "all_choices"),
label = "Filter by",
sep = attr(choices, "sep"),
drop_keys = FALSE
)
Arguments
vars |
( |
choices |
( These shall be filter values of the
The
|
selected |
( |
multiple |
( |
label |
(optional |
sep |
( |
drop_keys |
(optional |
Details
The filter_spec is used inside teal apps to allow filtering datasets
for their key variables. Imagine having an adverse events table. It has
the columns PARAMCD and CNSR. PARAMCD contains the levels
"OS", "PFS", "EFS". CNSR contains the levels "0" and "1".
The first example should show how a filter_spec setup will influence
the drop-down menu the app user will see.
Value
filter_spec-S3-class object or delayed_filter_spec-S3-class object.
Examples
# for Adverse Events table
filter_spec(
vars = c("PARAMCD", "CNSR"),
sep = "-",
choices = c("OS-1" = "OS-1", "OS-0" = "OS-0", "PFS-1" = "PFS-1"),
selected = "OS-1",
multiple = FALSE,
label = "Choose endpoint and Censor"
)
# filtering a single variable
filter_spec(
vars = c("PARAMCD"),
sep = "-",
choices = c("OS", "PFS", "EFS"),
selected = "OS",
multiple = FALSE,
label = "Choose endpoint"
)
# filtering a single variable by multiple levels of the variable
filter_spec(
vars = c("PARAMCD"),
sep = "-",
choices = c("OS", "PFS", "EFS"),
selected = c("OS", "PFS"),
multiple = TRUE,
label = "Choose endpoint"
)
# delayed version
filter_spec(
vars = variable_choices("ADSL", "SEX"),
sep = "-",
choices = value_choices("ADSL", "SEX", "SEX"),
selected = "F",
multiple = FALSE,
label = "Choose endpoint and Censor"
)
# using `choices_selected()`
filter_spec(
vars = choices_selected(variable_choices("ADSL", subset = c("SEX", "AGE")), "SEX", fixed = FALSE),
multiple = TRUE
)
filter_spec(
vars = choices_selected(variable_choices("ADSL"), "SEX", fixed = TRUE),
multiple = TRUE
)
# choose all choices
adsl_filter <- filter_spec(
vars = choices_selected(variable_choices("ADSL"), "SEX", fixed = FALSE),
choices = value_choices("ADSL", "SEX"),
selected = all_choices()
)