Module provides a dynamic and interactive way to view data.frames in a teal application.
It uses the DT package to display data tables in a paginated, searchable, and sortable format,
which helps to enhance data exploration and analysis.
Usage
tm_data_table(
label = "Data Table",
variables_selected = list(),
datasets_selected = deprecated(),
datanames = if (missing(datasets_selected)) "all" else datasets_selected,
dt_args = list(),
dt_options = list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100),
scrollX = TRUE),
server_rendering = FALSE,
pre_output = NULL,
post_output = NULL,
transformators = list()
)Arguments
- label
(
character(1)) Label shown in the navigation item for the module or module group. Formodules()defaults to"root". SeeDetails.- variables_selected
(
named list) 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. Use
datanamesinstead.- datanames
-
(
character) Names of the datasets relevant to the item. There are 2 reserved values that have specific behaviors:The keyword
"all"includes all datasets available in the data passed to the teal application.NULLhides the sidebar panel completely.If
transformatorsare specified, theirdatanamesare automatically added to thisdatanamesargument.
- dt_args
(
named list) Additional arguments to be passed toDT::datatable()(must not includedataoroptions).- dt_options
(
named list) Theoptionsargument toDT::datatable. By defaultlist(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)- server_rendering
(
logical) should the data table be rendered server side (seeserverargument ofDT::renderDataTable())- pre_output
(
shiny.tag) optional, text or UI element to be displayed before the module's output, providing context or a title. with text placed before the output to put the output into context. For example a title.- post_output
(
shiny.tag) optional, text or UI element to be displayed after the module's output, adding context or further instructions. Elements likeshiny::helpText()are useful.- transformators
(
listofteal_transform_module) that will be applied to transform module's data input. To learn more checkvignette("transform-input-data", package = "teal").
Details
The DT package has an option DT.TOJSON_ARGS to show Inf and NA in data tables.
Configure the DT.TOJSON_ARGS option via
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
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
iris <- iris
})
app <- init(
data = data,
modules = modules(
tm_data_table(
variables_selected = list(
iris = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
),
dt_args = list(caption = "IRIS Table Caption")
)
)
)
#> Initializing tm_data_table
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
ADSL <- teal.data::rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_data_table(
variables_selected = list(ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX")),
dt_args = list(caption = "ADSL Table Caption")
)
)
)
#> Initializing tm_data_table
if (interactive()) {
shinyApp(app$ui, app$server)
}