Class to encapsulate relational filtered datasets with its parents.
CDISCFilteredData.Rd
Details
The CDISCFilteredData
class implements logic to filter a relational
dataset by inheriting from FilteredData
.
A dataset can have up to one parent dataset. Rows are identified by the foreign
key and only those rows that appear in the parent dataset are kept in the filtered
dataset.
The teal UI works with objects of class FilteredData
which may mix CDISC and other
data (e.g. iris
).
Super class
teal.slice::FilteredData
-> CDISCFilteredData
Methods
Inherited methods
teal.slice::FilteredData$get_check()
teal.slice::FilteredData$get_code()
teal.slice::FilteredData$get_data()
teal.slice::FilteredData$get_datalabel()
teal.slice::FilteredData$get_filter_state()
teal.slice::FilteredData$get_filtered_dataset()
teal.slice::FilteredData$get_formatted_filter_state()
teal.slice::FilteredData$get_join_keys()
teal.slice::FilteredData$get_keys()
teal.slice::FilteredData$get_metadata()
teal.slice::FilteredData$get_varlabels()
teal.slice::FilteredData$get_varnames()
teal.slice::FilteredData$handle_active_datanames()
teal.slice::FilteredData$initialize()
teal.slice::FilteredData$remove_all_filter_states()
teal.slice::FilteredData$remove_filter_state()
teal.slice::FilteredData$restore_state_from_bookmark()
teal.slice::FilteredData$set_check()
teal.slice::FilteredData$set_code()
teal.slice::FilteredData$set_filter_state()
teal.slice::FilteredData$set_join_keys()
teal.slice::FilteredData$srv_filter_overview()
teal.slice::FilteredData$srv_filter_panel()
teal.slice::FilteredData$ui_filter_overview()
teal.slice::FilteredData$ui_filter_panel()
Method datanames()
Get datanames
The datanames are returned in the order in which they must be evaluated (in case of dependencies).
Method get_call()
Returns the filter call
to filter a single dataset including the inner_join
with its parent dataset. It assumes that the filtered datasets it depends
on are available.
Method get_filterable_varnames()
Gets variable names of a given dataname for the filtering. This excludes parent dataset variable names.
Method get_filter_overview()
Get filter overview table in form of X (filtered) / Y (non-filtered)
This is intended to be presented in the application.
Method set_dataset()
Add dataset
Add dataset and preserve all attributes attached to this object.
Technically set_dataset
created FilteredDataset
which keeps
dataset
for filtering purpose.
Examples
library(scda)
#>
library(teal.data)
ADSL <- synthetic_cdisc_data("latest")$adsl
ADTTE <- synthetic_cdisc_data("latest")$adtte
datasets <- teal.slice:::CDISCFilteredData$new(
list(
ADSL = list(dataset = ADSL, keys = c("STUDYID", "USUBJID")),
ADTTE = list(dataset = ADTTE, keys = c("STUDYID", "USUBJID", "PARAMCD"), parent = "ADSL")
),
check = FALSE,
join_keys = join_keys(join_key("ADSL", "ADTTE", c("STUDYID", "USUBJID")))
)
# to avoid using isolate(), you can provide a default isolate context by calling
# options(shiny.suppressMissingContextError = TRUE) #nolint
# don't forget to deactivate this option at the end
# options(shiny.suppressMissingContextError = FALSE) #nolint
isolate({
datasets$datanames()
# number observations and subjects of filtered/non-filtered dataset
datasets$get_filter_overview("ADSL")
print(datasets$get_call("ADSL"))
print(datasets$get_call("ADTTE"))
df <- datasets$get_data("ADSL", filtered = FALSE)
print(df)
})
#> $filter
#> ADSL_FILTERED <- ADSL
#>
#> $filter
#> ADTTE_FILTERED_ALONE <- ADTTE
#>
#> [[2]]
#> ADTTE_FILTERED <- dplyr::inner_join(x = ADTTE_FILTERED_ALONE,
#> y = ADSL_FILTERED[, c("STUDYID", "USUBJID"), drop = FALSE],
#> by = c("STUDYID", "USUBJID"))
#>
#> # A tibble: 400 × 44
#> STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL
#> <chr> <chr> <chr> <chr> <int> <fct> <fct> <fct> <fct> <fct> <fct>
#> 1 AB12345 AB12345-C… id-128 CHN-3 32 YEARS M ASIAN NOT H… CHN N
#> 2 AB12345 AB12345-C… id-262 CHN-15 35 YEARS M BLAC… NOT H… CHN N
#> 3 AB12345 AB12345-R… id-378 RUS-3 30 YEARS F ASIAN NOT H… RUS N
#> 4 AB12345 AB12345-C… id-220 CHN-11 26 YEARS F ASIAN NOT H… CHN N
#> 5 AB12345 AB12345-C… id-267 CHN-7 40 YEARS M ASIAN UNKNO… CHN N
#> 6 AB12345 AB12345-C… id-201 CHN-15 49 YEARS M ASIAN NOT H… CHN N
#> 7 AB12345 AB12345-U… id-45 USA-1 34 YEARS F ASIAN NOT H… USA N
#> 8 AB12345 AB12345-U… id-261 USA-1 32 YEARS F ASIAN NOT H… USA N
#> 9 AB12345 AB12345-N… id-173 NGA-11 24 YEARS F BLAC… NOT H… NGA N
#> 10 AB12345 AB12345-C… id-307 CHN-1 24 YEARS M ASIAN NOT H… CHN N
#> # … with 390 more rows, and 33 more variables: INVID <chr>, INVNAM <chr>,
#> # ARM <fct>, ARMCD <fct>, ACTARM <fct>, ACTARMCD <fct>, TRT01P <fct>,
#> # TRT01A <fct>, REGION1 <fct>, STRATA1 <fct>, STRATA2 <fct>, BMRKR1 <dbl>,
#> # BMRKR2 <fct>, ITTFL <fct>, SAFFL <fct>, BMEASIFL <fct>, BEP01FL <fct>,
#> # RANDDT <date>, TRTSDTM <dttm>, TRTEDTM <dttm>, EOSSTT <fct>, EOTSTT <fct>,
#> # EOSDT <date>, EOSDY <int>, DCSREAS <fct>, DTHDT <date>, DTHCAUS <fct>,
#> # DTHCAT <fct>, LDDTHELD <int>, LDDTHGR1 <fct>, LSTALVDT <date>, …
datasets$set_filter_state(list(ADTTE = list(PARAMCD = "OS")))
isolate(datasets$get_filter_state())
#> $ADTTE
#> $ADTTE$PARAMCD
#> $ADTTE$PARAMCD$selected
#> [1] "OS"
#>
#> $ADTTE$PARAMCD$keep_na
#> [1] FALSE
#>
#>
#>