tm_g_bivariate {teal.modules.general}R Documentation

teal module: Univariate and bivariate visualizations

Description

Module enables the creation of univariate and bivariate plots, facilitating the exploration of data distributions and relationships between two variables.

Usage

tm_g_bivariate(
  label = "Bivariate Plots",
  x,
  y,
  row_facet = NULL,
  col_facet = NULL,
  facet = !is.null(row_facet) || !is.null(col_facet),
  color = NULL,
  fill = NULL,
  size = NULL,
  use_density = FALSE,
  color_settings = FALSE,
  free_x_scales = FALSE,
  free_y_scales = FALSE,
  plot_height = c(600, 200, 2000),
  plot_width = NULL,
  rotate_xaxis_labels = FALSE,
  swap_axes = FALSE,
  ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
  ggplot2_args = teal.widgets::ggplot2_args(),
  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.

x

(data_extract_spec or list of multiple data_extract_spec) Variable names selected to plot along the x-axis by default. Can be numeric, factor or character. No empty selections are allowed.

y

(data_extract_spec or list of multiple data_extract_spec) Variable names selected to plot along the y-axis by default. Can be numeric, factor or character.

row_facet

(data_extract_spec or list of multiple data_extract_spec) optional, specification of the data variable(s) to use for faceting rows.

col_facet

(data_extract_spec or list of multiple data_extract_spec) optional, specification of the data variable(s) to use for faceting columns.

facet

(logical) optional, specifies whether the facet encodings ui elements are toggled on and shown to the user by default. Defaults to TRUE if either row_facet or column_facet are supplied.

color

(data_extract_spec or list of multiple data_extract_spec) optional, specification of the data variable(s) selected for the outline color inside the coloring settings. It will be applied when color_settings is set to TRUE.

fill

(data_extract_spec or list of multiple data_extract_spec) optional, specification of the data variable(s) selected for the fill color inside the coloring settings. It will be applied when color_settings is set to TRUE.

size

(data_extract_spec or list of multiple data_extract_spec) optional, specification of the data variable(s) selected for the size of geom_point plots inside the coloring settings. It will be applied when color_settings is set to TRUE.

use_density

(logical) optional, indicates whether to plot density (TRUE) or frequency (FALSE). Defaults to frequency (FALSE).

color_settings

(logical) Whether coloring, filling and size should be applied and UI tool offered to the user.

free_x_scales

(logical) optional, whether X scaling shall be changeable. Does not allow scaling to be changed by default (FALSE).

free_y_scales

(logical) optional, whether Y scaling shall be changeable. Does not allow scaling to be changed by default (FALSE).

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.

rotate_xaxis_labels

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

swap_axes

(logical) optional, whether to swap X and Y axes. Defaults to FALSE.

ggtheme

(character) optional, ggplot2 theme to be used by default. 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, 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.

Details

This is a general module to visualize 1 & 2 dimensional data.

Value

Object of class teal_module to be used in teal applications.

Note

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

Examples

library(teal.widgets)

# general data example
data <- teal_data()
data <- within(data, {
  require(nestcolor)
  CO2 <- data.frame(CO2)
})
datanames(data) <- c("CO2")
join_keys(data) <- default_cdisc_join_keys[datanames(data)]

app <- init(
  data = data,
  modules = modules(
    tm_g_bivariate(
      x = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "conc",
          fixed = FALSE
        )
      ),
      y = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "uptake",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      row_facet = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "Type",
          fixed = FALSE
        )
      ),
      col_facet = data_extract_spec(
        dataname = "CO2",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["CO2"]]),
          selected = "Treatment",
          fixed = FALSE
        )
      ),
      ggplot2_args = ggplot2_args(
        labs = list(subtitle = "Plot generated by Bivariate Module")
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


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

app <- init(
  data = data,
  modules = modules(
    tm_g_bivariate(
      x = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["ADSL"]]),
          selected = "AGE",
          fixed = FALSE
        )
      ),
      y = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["ADSL"]]),
          selected = "SEX",
          multiple = FALSE,
          fixed = FALSE
        )
      ),
      row_facet = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["ADSL"]]),
          selected = "ARM",
          fixed = FALSE
        )
      ),
      col_facet = data_extract_spec(
        dataname = "ADSL",
        select = select_spec(
          label = "Select variable:",
          choices = variable_choices(data[["ADSL"]]),
          selected = "COUNTRY",
          fixed = FALSE
        )
      ),
      ggplot2_args = ggplot2_args(
        labs = list(subtitle = "Plot generated by Bivariate Module")
      )
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}


[Package teal.modules.general version 0.3.0 Index]