Skip to contents

Response Plots

Usage

tm_g_response(
  label = "Response Plot",
  response,
  x,
  row_facet = NULL,
  col_facet = NULL,
  coord_flip = FALSE,
  count_labels = TRUE,
  rotate_xaxis_labels = FALSE,
  freq = FALSE,
  plot_height = c(600, 400, 5000),
  plot_width = NULL,
  ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void",
    "test"),
  ggplot2_args = teal.widgets::ggplot2_args(),
  pre_output = NULL,
  post_output = NULL
)

Arguments

label

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

response

(data_extract_spec or list of multiple data_extract_spec) Which variable to use as the response. You can define one fixed column by using the setting fixed = TRUE inside the select_spec. data_extract_spec must not allow multiple selection in this case.

x

(data_extract_spec or list of multiple data_extract_spec) Which variable to use on the X-axis of the response plot. Allow the user to select multiple columns from the data allowed in teal. data_extract_spec must not allow multiple selection in this case.

row_facet

optional, (data_extract_spec or list of multiple data_extract_spec) Which data columns to use for faceting rows.

col_facet

optional, (data_extract_spec or list of multiple data_extract_spec) Which data to use for faceting columns.

coord_flip

optional, (logical) Whether to flip coordinates between x and response.

count_labels

optional, (logical) Whether to show count labels. Defaults to TRUE.

rotate_xaxis_labels

optional, (logical) Whether to rotate plot X axis labels. Does not rotate by default (FALSE).

freq

optional, (logical) Whether to display frequency (TRUE) or density (FALSE). Defaults to density (FALSE).

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.

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

(ggplot2_args) object created by teal.widgets::ggplot2_args() with settings for the module plot. The argument is merged with options variable teal.ggplot2_args and default module setup.

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.

Note

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

Examples

# Response plot with selected response (BMRKR1) and selected x variable (RACE)
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_response(
      label = "Response Plots",
      response = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(ADSL, c("BMRKR2", "COUNTRY")),
          selected = "BMRKR2",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      x = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(ADSL, c("SEX", "RACE")),
          selected = "RACE",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      ggplot2_args = teal.widgets::ggplot2_args(labs = list(subtitle = "Plot generated by Response Module"))
    )
  )
)
#> [INFO] 2022-06-14 17:42:35.5875 pid:1110 token:[] teal.modules.general Initializing tm_g_response
if (FALSE) {
shinyApp(app$ui, app$server)
}