Data Table Viewer Teal Module
tm_data_table.Rd
A data table viewer shows the data using a paginated table.
Arguments
- label
(
character
) Label shown in the navigation item for the module.- variables_selected
(
list
) A named list of character vectors of the variables (i.e. columns) which should be initially shown for each dataset. Names of list elements should correspond to the names of the datasets available in the app. If no entry is specified for a dataset, the first six variables from that dataset will initially be shown.- datasets_selected
(
character
) A vector of datasets which should be shown and in what order. Names in the vector have to correspond with datasets names. If vector of length zero (default) then all datasets are shown.- dt_args
(named
list
) Additional arguments to be passed toDT::datatable
(must not includedata
oroptions
).- dt_options
(named
list
) Theoptions
argument toDT::datatable
. By defaultlist(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)
- pre_output
(
shiny.tag
, optional)
with text placed before the output to put the output into context. For example a title.- post_output
(
shiny.tag
, optional) with text placed after the output to put the output into context. For example theshiny::helpText()
elements are useful.
Details
The DT
package has an option DT.TOJSON_ARGS
to show Inf
and NA
in data tables. If this is something
you require then set options(DT.TOJSON_ARGS = list(na = "string"))
before running the module.
Note though that sorting of numeric columns with NA
/Inf
will be lexicographic not numerical.
Examples
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"),
check = TRUE
),
modules = modules(
tm_data_table(
variables_selected = list(ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX")),
dt_args = list(caption = "ADSL Table Caption")
)
)
)
#> [INFO] 2022-06-14 17:42:11.9762 pid:1110 token:[] teal.modules.general Initializing tm_data_table
if (FALSE) {
shinyApp(app$ui, app$server)
}
# two-datasets example
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
ADTTE <- synthetic_cdisc_data("latest")$adtte
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"),
cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- synthetic_cdisc_data(\"latest\")$adtte"),
check = TRUE
),
modules = modules(
tm_data_table(
variables_selected = list(
ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX"),
ADTTE = c(
"STUDYID", "USUBJID", "SUBJID", "SITEID",
"PARAM", "PARAMCD", "ARM", "ARMCD", "AVAL", "CNSR"
)
)
)
)
)
#> [INFO] 2022-06-14 17:42:15.4503 pid:1110 token:[] teal.modules.general Initializing tm_data_table
if (FALSE) {
shinyApp(app$ui, app$server)
}
# datasets: subsetting or changing order of datasets inside tm_data_table
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
ADLB <- synthetic_cdisc_data("latest")$adlb
ADTTE <- synthetic_cdisc_data("latest")$adtte
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"),
cdisc_dataset("ADLB", ADLB, code = "ADLB <- synthetic_cdisc_data(\"latest\")$adlb"),
cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- synthetic_cdisc_data(\"latest\")$adtte"),
check = TRUE
),
modules = modules(
tm_data_table(
variables_selected = list(
ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX"),
ADLB = c(
"STUDYID", "USUBJID", "SUBJID", "SITEID",
"PARAM", "PARAMCD", "AVISIT", "AVISITN", "AVAL", "CHG"
)
),
datasets_selected = c("ADTTE", "ADLB", "ADSL")
)
)
)
#> [INFO] 2022-06-14 17:42:20.7656 pid:1110 token:[] teal.modules.general Initializing tm_data_table
if (FALSE) {
shinyApp(app$ui, app$server)
}
# advanced usage of DT options and extensions
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
ADTTE <- synthetic_cdisc_data("latest")$adtte
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"),
cdisc_dataset("ADTTE", ADTTE, code = "ADTTE <- synthetic_cdisc_data(\"latest\")$adtte"),
check = TRUE
),
modules = modules(
tm_data_table(
dt_args = list(extensions = c("Buttons", "ColReorder", "FixedHeader")),
dt_options = list(
searching = FALSE,
pageLength = 30,
lengthMenu = c(5, 15, 25, 50, 100),
scrollX = FALSE,
dom = "lBrtip",
buttons = c("copy", "csv", "excel", "pdf", "print"),
colReorder = TRUE,
fixedHeader = TRUE
)
)
)
)
#> [INFO] 2022-06-14 17:42:24.2636 pid:1110 token:[] teal.modules.general Initializing tm_data_table
if (FALSE) {
shinyApp(app$ui, app$server)
}