Module provides a dynamic and interactive way to view data.frame
s 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.
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. Names in the vector have to correspond with datasets names. If vector oflength == 0
(default) then all datasets are shown. Note: Only datasets of thedata.frame
class are compatible.- 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)
- server_rendering
(
logical
) should the data table be rendered server side (seeserver
argument 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.
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 <- 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)
}