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. Formodules()
defaults to"root"
. SeeDetails
.- x
(
data_extract_spec
orlist
of multipledata_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
orlist
of multipledata_extract_spec
) Variable names selected to plot along the y-axis by default. Can be numeric, factor or character.- row_facet
(
data_extract_spec
orlist
of multipledata_extract_spec
) optional, specification of the data variable(s) to use for faceting rows.- col_facet
(
data_extract_spec
orlist
of multipledata_extract_spec
) optional, specification of the data variable(s) to use for faceting columns.- facet
(
logical
) optional, specifies whether the facet encodingsui
elements are toggled on and shown to the user by default. Defaults toTRUE
if eitherrow_facet
orcolumn_facet
are supplied.- color
(
data_extract_spec
orlist
of multipledata_extract_spec
) optional, specification of the data variable(s) selected for the outline color inside the coloring settings. It will be applied whencolor_settings
is set toTRUE
.- fill
(
data_extract_spec
orlist
of multipledata_extract_spec
) optional, specification of the data variable(s) selected for the fill color inside the coloring settings. It will be applied whencolor_settings
is set toTRUE
.- size
(
data_extract_spec
orlist
of multipledata_extract_spec
) optional, specification of the data variable(s) selected for the size ofgeom_point
plots inside the coloring settings. It will be applied whencolor_settings
is set toTRUE
.- 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 andUI
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 ofvalue
,min
, andmax
intended for use with a slider UI element.- plot_width
(
numeric
) optional, specifies the plot width as a three-element vector ofvalue
,min
, andmax
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 toFALSE
.- ggtheme
(
character
) optional,ggplot2
theme to be used by default. 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_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 likeshiny::helpText()
are useful.
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")
)
)
)
)
#> [INFO] 2024-03-05 18:46:07.3463 pid:1279 token:[] teal.modules.general Initializing tm_g_bivariate
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")
)
)
)
)
#> [INFO] 2024-03-05 18:46:07.4494 pid:1279 token:[] teal.modules.general Initializing tm_g_bivariate
if (interactive()) {
shinyApp(app$ui, app$server)
}