Skip to contents

Scatterplot and Regression Model

Usage

tm_a_regression(
  label = "Regression Analysis",
  regressor,
  response,
  plot_height = c(600, 200, 2000),
  plot_width = NULL,
  alpha = c(1, 0, 1),
  size = c(2, 1, 8),
  ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void",
    "test"),
  ggplot2_args = teal.widgets::ggplot2_args(),
  pre_output = NULL,
  post_output = NULL,
  default_plot_type = 1,
  default_outlier_label = "USUBJID"
)

Arguments

label

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

regressor

(data_extract_spec or list of multiple data_extract_spec) Regressor variables from an incoming dataset with filtering and selecting.

response

(data_extract_spec or list of multiple data_extract_spec) Response variables from an incoming dataset with filtering and selecting.

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.

alpha

optional, (numeric) If scalar then the plot points will have a fixed opacity. If a slider should be presented to adjust the plot point opacity dynamically then it can be a vector of length three with c(value, min, max).

size

optional, (numeric) If scalar then the plot point sizes will have a fixed size If a slider should be presented to adjust the plot point sizes dynamically then it can be a vector of length three with c(value, min, max).

ggtheme

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".

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", "Response vs Regressor", "Residuals vs Fitted", "Scale-Location", "Cook's distance", "Residuals vs Leverage"", "Cook's dist vs Leverage").

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

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.

default_plot_type

optional, (numeric) Defaults to Response vs Regressor.

  1. Response vs Regressor

  2. Residuals vs Fitted

  3. Normal Q-Q

  4. Scale-Location

  5. Cook's distance

  6. Residuals vs Leverage

  7. Cook's dist vs Leverage

default_outlier_label

optional, (character) The default column selected to label outliers.

Note

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

Examples

# Regression graphs from selected response variable (BMRKR1) and
# selected regressors (AGE)
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_a_regression(
      label = "Regression",
      response = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = "BMRKR1",
          selected = "BMRKR1",
          multiple = FALSE,
          fixed = TRUE
        )
      ),
      regressor = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variables:",
          choices = variable_choices(ADSL, c("AGE", "SEX", "RACE")),
          selected = "AGE",
          multiple = TRUE,
          fixed = FALSE
        )
      ),
      ggplot2_args = teal.widgets::ggplot2_args(labs = list(subtitle = "Plot generated by Regression Module"))
    )
  )
)
#> [INFO] 2022-06-14 17:42:09.7748 pid:1110 token:[] teal.modules.general Initializing tm_a_regression
if (FALSE) {
shinyApp(app$ui, app$server)
}