Univariate and bivariate visualizations
tm_g_bivariate.RdUnivariate and bivariate visualizations
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",
"test"),
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. Any label possible except"global_filters"- read more inmappingargument of teal_slices.- x
(
data_extract_specorlistof multipledata_extract_spec) Variable names selected to plot along the x-axis by default. Variable can be numeric, factor or character. No empty selections are allowed!- y
(
data_extract_specorlistof multipledata_extract_spec) Variable names selected to plot along the y-axis by default. Variable can be numeric, factor or character.- row_facet
optional, (
data_extract_specorlistof multipledata_extract_spec) Variables for row facetting.- col_facet
optional, (
data_extract_specorlistof multipledata_extract_spec) Variables for col facetting.- facet
optional, (
logical) to specify whether the facet encodingsuielements are toggled on and shown to the user by default. Defaults toTRUEif eitherrow_facetorcolumn_facetare supplied.- color
optional, (
data_extract_specorlistof multipledata_extract_spec) Variables selected for the outline color inside the coloring settings. It will be applied whencolor_settingsis set toTRUE.- fill
optional, (
data_extract_specorlistof multipledata_extract_spec) Variables selected for the fill color inside the coloring settings. It will be applied whencolor_settingsis set toTRUE.- size
optional, (
data_extract_specorlistof multipledata_extract_spec) Variables selected for the size ofgeom_pointplots inside the coloring settings. It will be applied whencolor_settingsis set toTRUE.- use_density
optional, (
logical) value for whether density (TRUE) is plotted or frequency (FALSE). Defaults to frequency (FALSE).- color_settings
(
logical) Whether coloring, filling and size should be applied andUItool offered to the user.- free_x_scales
optional, (
logical) Whether X scaling shall be changeable. Does not allow scaling to be changed by default (FALSE).- free_y_scales
optional, (
logical) Whether Y scaling shall be changeable. Does not allow scaling to be changed by default (FALSE).- plot_height
optional, (
numeric) A vector of length three withc(value, min and max)for a slider encoding the plot height.- plot_width
optional, (
numeric) A vector of length three withc(value, min and max)for a slider encoding the plot width.- rotate_xaxis_labels
optional, (
logical) Whether to rotate plot X axis labels. Does not rotate by default (FALSE).- swap_axes
optional, (
logical) Whether to swap X and Y axes. Defaults toFALSE.- ggtheme
optional, (
character)ggplot2theme to be used by default. One ofc("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 byteal.widgets::ggplot2_args()with settings for the module plot. The argument is merged with options variableteal.ggplot2_argsand 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 theshiny::helpText()elements are useful.
Note
For more examples, please see the vignette "Using bivariate plot" via
vignette("using-bivariate-plot", package = "teal.modules.general").
Examples
# Bivariate plot of selected variable (AGE) against selected (SEX)
ADSL <- teal.modules.general::rADSL
app <- teal::init(
data = teal.data::cdisc_data(
teal.data::cdisc_dataset("ADSL", ADSL, code = "ADSL <- teal.modules.general::rADSL"),
check = TRUE
),
modules = teal::modules(
teal.modules.general::tm_g_bivariate(
x = teal.transform::data_extract_spec(
dataname = "ADSL",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(ADSL),
selected = "AGE",
fixed = FALSE
)
),
y = teal.transform::data_extract_spec(
dataname = "ADSL",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(ADSL),
selected = "SEX",
multiple = FALSE,
fixed = FALSE
)
),
row_facet = teal.transform::data_extract_spec(
dataname = "ADSL",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(ADSL),
selected = "ARM",
fixed = FALSE
)
),
col_facet = teal.transform::data_extract_spec(
dataname = "ADSL",
select = teal.transform::select_spec(
label = "Select variable:",
choices = teal.transform::variable_choices(ADSL),
selected = "COUNTRY",
fixed = FALSE
)
),
ggplot2_args = teal.widgets::ggplot2_args(
labs = list(subtitle = "Plot generated by Bivariate Module")
)
)
)
)
#> [INFO] 2023-08-14 13:51:34.9080 pid:1296 token:[] teal.modules.general Initializing tm_g_bivariate
if (interactive()) {
shinyApp(app$ui, app$server)
}