Skip to contents

Stack Plots of variables and show association with reference variable

Usage

tm_g_association(
  label = "Association",
  ref,
  vars,
  show_association = TRUE,
  plot_height = c(600, 400, 5000),
  plot_width = NULL,
  distribution_theme = c("gray", "bw", "linedraw", "light", "dark", "minimal",
    "classic", "void", "test"),
  association_theme = c("gray", "bw", "linedraw", "light", "dark", "minimal",
    "classic", "void", "test"),
  pre_output = NULL,
  post_output = NULL,
  ggplot2_args = teal.widgets::ggplot2_args()
)

Arguments

label

(character) Label shown in the navigation item for the module.

ref

(data_extract_spec or list of multiple data_extract_spec) reference variable, must set multiple = FALSE.

vars

(data_extract_spec or list of multiple data_extract_spec) associated variables.

show_association

optional, (logical) Whether show association of vars with reference variable. Defaults to TRUE.

plot_height

optional, (numeric) A vector of length three with c(value, min and max) for a slider encoding the plot height.

plot_width

optional, (numeric) A vector of length three with c(value, min and max) for a slider encoding the plot width.

distribution_theme

optional, (character) ggplot2 theme to be used by default. One of c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void", "test"). Each theme can be chosen by the user during the session. Defaults to "gray".

association_theme

optional, (character) ggplot2 theme to be used by default. One of c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void", "test"). Each theme can be chosen by the user during the session. Defaults to "gray".

pre_output

(shiny.tag, optional)
with text placed before the output to put the output into context. For example a title.

post_output

(shiny.tag, optional) with text placed after the output to put the output into context. For example the shiny::helpText() elements are useful.

ggplot2_args

optional, (ggplot2_args) 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", "Bivariate1", "Bivariate2").

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

Note

For more examples, please see the vignette "Using association plot" via vignette("using-association-plot", package = "teal.modules.general").

Examples

# Association plot of selected reference variable (SEX)
# against other selected variables (BMRKR1)
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl

app <- init(
  data = cdisc_data(
    cdisc_dataset("ADSL", ADSL, code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"),
    check = TRUE
  ),
  modules = modules(
    tm_g_association(
      ref = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(
            ADSL,
            c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
          ),
          selected = "RACE",
          fixed = FALSE
        )
      ),
      vars = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variables:",
          choices = variable_choices(
            ADSL,
            c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2")
          ),
          selected = "BMRKR2",
          multiple = TRUE,
          fixed = FALSE
        )
      ),
      ggplot2_args = teal.widgets::ggplot2_args(labs = list(subtitle = "Plot generated by Association Module"))
    )
  )
)
#> [INFO] 2022-06-14 17:42:29.5656 pid:1110 token:[] teal.modules.general Initializing tm_g_association
if (FALSE) {
shinyApp(app$ui, app$server)
}