tm_data_table {teal.modules.general}R Documentation

teal module: Data table viewer

Description

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 = character(0),
  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
)

Arguments

label

(character(1)) Label shown in the navigation item for the module or module group. For modules() defaults to "root". See Details.

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 of length == 0 (default) then all datasets are shown. Note: Only datasets of the data.frame class are compatible.

dt_args

(⁠named list⁠) Additional arguments to be passed to DT::datatable() (must not include data or options).

dt_options

(⁠named list⁠) The options argument to DT::datatable. By default list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100), scrollX = TRUE)

server_rendering

(logical) should the data table be rendered server side (see server argument of DT::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 like shiny::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.

Value

Object of class teal_module to be used in teal applications.

Examples

# general data example
data <- teal_data()
data <- within(data, {
  require(nestcolor)
  iris <- iris
})
datanames(data) <- c("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 = "ADSL Table Caption")
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

# CDISC data example
data <- teal_data()
data <- within(data, {
  require(nestcolor)
  ADSL <- rADSL
})
datanames(data) <- "ADSL"
join_keys(data) <- default_cdisc_join_keys[datanames(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")
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


[Package teal.modules.general version 0.3.0 Index]