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
)

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.

Value

Object of class teal_module to be used in teal applications.

Examples

library(teal.widgets)

# module specification used in apps below
tm_missing_data_module <- tm_missing_data(
  ggplot2_args = list(
    "Combinations Hist" = ggplot2_args(
      labs = list(subtitle = "Plot produced by Missing Data Module", caption = NULL)
    ),
    "Combinations Main" = ggplot2_args(labs = list(title = NULL))
  )
)
#> [INFO] 2024-03-05 18:46:10.8053 pid:1279 token:[] teal.modules.general Initializing tm_missing_data

# 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"]])
})
datanames(data) <- c("iris", "mtcars")

app <- init(
  data = data,
  modules = modules(tm_missing_data_module)
)
#> Warning: 'package:nestcolor' may not be available when loading
if (interactive()) {
  shinyApp(app$ui, app$server)
}

# CDISC example data
data <- teal_data()
data <- within(data, {
  require(nestcolor)
  ADSL <- rADSL
  ADRS <- rADRS
})
datanames(data) <- c("ADSL", "ADRS")
join_keys(data) <- default_cdisc_join_keys[datanames(data)]

app <- init(
  data = data,
  modules = modules(tm_missing_data_module)
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}