Skip to contents

This module analyzes missing data in data.frames to help users explore missing observations and gain insights into the completeness of their data. It is useful for clinical data analysis within the context of CDISC standards and adaptable for general data analysis purposes.

Usage

tm_missing_data(
  label = "Missing data",
  plot_height = c(600, 400, 5000),
  plot_width = NULL,
  parent_dataname = "ADSL",
  ggtheme = c("classic", "gray", "bw", "linedraw", "light", "dark", "minimal", "void"),
  ggplot2_args = list(`Combinations Hist` = teal.widgets::ggplot2_args(labs =
    list(caption = NULL)), `Combinations Main` = teal.widgets::ggplot2_args(labs =
    list(title = NULL))),
  pre_output = NULL,
  post_output = NULL,
  decorators = NULL
)

Arguments

label

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

plot_height

(numeric) optional, specifies the plot height as a three-element vector of value, min, and max intended for use with a slider UI element.

plot_width

(numeric) optional, specifies the plot width as a three-element vector of value, min, and max for a slider encoding the plot width.

parent_dataname

(character(1)) Specifies the parent dataset name. Default is ADSL for CDISC data. If provided and exists, enables additional analysis "by subject". For non-CDISC data, this parameter can be ignored.

ggtheme

(character) optional, specifies the default ggplot2 theme for plots. Defaults to classic.

ggplot2_args

(ggplot2_args) optional, object created by teal.widgets::ggplot2_args() with settings for all the plots or named list of ggplot2_args objects for plot-specific settings. The argument is merged with options variable teal.ggplot2_args and default module setup.

List names should match the following: c("default", "Summary Obs", "Summary Patients", "Combinations Main", "Combinations Hist", "By Subject").

For more details see the vignette: vignette("custom-ggplot2-arguments", package = "teal.widgets").

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.

decorators

[Experimental] (list of teal_transform_module, named list of teal_transform_module or NULL) optional, if not NULL, decorator for tables or plots included in the module. When a named list of teal_transform_module, the decorators are applied to the respective output objects.

Otherwise, the decorators are applied to all objects, which is equivalent as using the name default.

See section "Decorating tm_missing_data" below for more details.

Value

Object of class teal_module to be used in teal applications.

Decorating tm_missing_data

This module generates the following objects, which can be modified in place using decorators:

Decorators can be applied to all outputs or only to specific objects using a named list of teal_transform_module objects. The "default" name is reserved for decorators that are applied to all outputs. See code snippet below:

tm_missing_data(
   ..., # arguments for module
   decorators = list(
     default = list(teal_transform_module(...)), # applied to all outputs
     summary_plot = list(teal_transform_module(...)), # applied only to `summary_plot` output
     combination_plot = list(teal_transform_module(...)) # applied only to `combination_plot` output
     by_subject_plot = list(teal_transform_module(...)) # applied only to `by_subject_plot` output
     table = list(teal_transform_module(...)) # applied only to `table` output
   )
)

For additional details and examples of decorators, refer to the vignette vignette("decorate-modules-output", package = "teal") or the teal::teal_transform_module() documentation.

Examples in Shinylive

example-1

Open in Shinylive

example-2

Open in Shinylive

Examples

# general example data
data <- teal_data()
data <- within(data, {
  require(nestcolor)

  add_nas <- function(x) {
    x[sample(seq_along(x), floor(length(x) * runif(1, .05, .17)))] <- NA
    x
  }

  iris <- iris
  mtcars <- mtcars

  iris[] <- lapply(iris, add_nas)
  mtcars[] <- lapply(mtcars, add_nas)
  mtcars[["cyl"]] <- as.factor(mtcars[["cyl"]])
  mtcars[["gear"]] <- as.factor(mtcars[["gear"]])
})

app <- init(
  data = data,
  modules = modules(
    tm_missing_data()
  )
)
#> Initializing tm_missing_data
#> Warning: 'package:rlang' may not be available when loading
#> Initializing reporter_previewer_module
if (interactive()) {
  shinyApp(app$ui, app$server)
}
# CDISC example data
data <- teal_data()
data <- within(data, {
  require(nestcolor)
  ADSL <- teal.data::rADSL
  ADRS <- rADRS
})
join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_missing_data()
  )
)
#> Initializing tm_missing_data
#> Initializing reporter_previewer_module
if (interactive()) {
  shinyApp(app$ui, app$server)
}