tm_g_scatterplot {teal.modules.general} | R Documentation |
teal
module: Scatterplot
Description
Generates a customizable scatterplot using ggplot2
.
This module allows users to select variables for the x and y axes,
color and size encodings, faceting options, and more. It supports log transformations,
trend line additions, and dynamic adjustments of point opacity and size through UI controls.
Usage
tm_g_scatterplot(
label = "Scatterplot",
x,
y,
color_by = NULL,
size_by = NULL,
row_facet = NULL,
col_facet = NULL,
plot_height = c(600, 200, 2000),
plot_width = NULL,
alpha = c(1, 0, 1),
shape = shape_names,
size = c(5, 1, 15),
max_deg = 5L,
rotate_xaxis_labels = FALSE,
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
pre_output = NULL,
post_output = NULL,
table_dec = 4,
ggplot2_args = teal.widgets::ggplot2_args()
)
Arguments
label |
( |
x |
( |
y |
( |
color_by |
( |
size_by |
( |
row_facet |
( |
col_facet |
( |
plot_height |
( |
plot_width |
( |
alpha |
(
|
shape |
( |
size |
(
|
max_deg |
( |
rotate_xaxis_labels |
( |
ggtheme |
( |
pre_output |
( |
post_output |
( |
table_dec |
( |
ggplot2_args |
( For more details see the vignette: |
Value
Object of class teal_module
to be used in teal
applications.
Note
For more examples, please see the vignette "Using scatterplot" via
vignette("using-scatterplot", package = "teal.modules.general")
.
Examples
library(teal.widgets)
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
CO2 <- CO2
})
datanames(data) <- "CO2"
app <- init(
data = data,
modules = modules(
tm_g_scatterplot(
label = "Scatterplot Choices",
x = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
selected = "conc",
multiple = FALSE,
fixed = FALSE
)
),
y = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
selected = "uptake",
multiple = FALSE,
fixed = FALSE
)
),
color_by = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = variable_choices(
data[["CO2"]],
c("Plant", "Type", "Treatment", "conc", "uptake")
),
selected = NULL,
multiple = FALSE,
fixed = FALSE
)
),
size_by = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["CO2"]], c("conc", "uptake")),
selected = "uptake",
multiple = FALSE,
fixed = FALSE
)
),
row_facet = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
selected = NULL,
multiple = FALSE,
fixed = FALSE
)
),
col_facet = data_extract_spec(
dataname = "CO2",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")),
selected = NULL,
multiple = FALSE,
fixed = FALSE
)
),
ggplot2_args = ggplot2_args(
labs = list(subtitle = "Plot generated by Scatterplot 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_scatterplot(
label = "Scatterplot Choices",
x = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1", "BMRKR2")),
selected = "AGE",
multiple = FALSE,
fixed = FALSE
)
),
y = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1", "BMRKR2")),
selected = "BMRKR1",
multiple = FALSE,
fixed = FALSE
)
),
color_by = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(
data[["ADSL"]],
c("AGE", "BMRKR1", "BMRKR2", "RACE", "REGION1")
),
selected = NULL,
multiple = FALSE,
fixed = FALSE
)
),
size_by = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")),
selected = "AGE",
multiple = FALSE,
fixed = FALSE
)
),
row_facet = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["ADSL"]], c("BMRKR2", "RACE", "REGION1")),
selected = NULL,
multiple = FALSE,
fixed = FALSE
)
),
col_facet = data_extract_spec(
dataname = "ADSL",
select = select_spec(
label = "Select variable:",
choices = variable_choices(data[["ADSL"]], c("BMRKR2", "RACE", "REGION1")),
selected = NULL,
multiple = FALSE,
fixed = FALSE
)
),
ggplot2_args = ggplot2_args(
labs = list(subtitle = "Plot generated by Scatterplot Module")
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}