View source: R/tm_g_association.R
| tm_g_association | R Documentation |
teal module: Stack plots of variables and show association with reference variableModule provides functionality for visualizing the distribution of variables and their association with a reference variable. It supports configuring the appearance of the plots, including themes and whether to show associations.
tm_g_association(
label = "Association",
ref = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(choices =
is.numeric | teal.picks::is_categorical(min.len = 2, max.len = 10), selected = 1L),
teal.picks::values()),
vars,
show_association = TRUE,
plot_height = c(600, 400, 5000),
plot_width = NULL,
distribution_theme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic",
"void"),
association_theme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic",
"void"),
pre_output = NULL,
post_output = NULL,
ggplot2_args = teal.widgets::ggplot2_args(),
transformators = list(),
decorators = list()
)
Object of class teal_module to be used in teal applications.
This module generates the following objects, which can be modified in place using decorators:
plot (grob created with ggplot2::ggplotGrob())
A Decorator is applied to the specific output using a named list of teal_transform_module objects.
The name of this list corresponds to the name of the output to which the decorator is applied.
See code snippet below:
tm_g_association(
..., # arguments for module
decorators = list(
plot = teal_transform_module(...) # applied to the `plot` output
)
)
For additional details and examples of decorators, refer to the vignette
vignette("decorate-module-output", package = "teal.modules.general").
To learn more please refer to the vignette
vignette("transform-module-output", package = "teal") or the teal::teal_transform_module() documentation.
This module returns an object of class teal_module, that contains a server function.
Since the server function returns a teal_report object, this makes this module reportable, which means that
the reporting functionality will be turned on automatically by the teal framework.
For more information on reporting in teal, see the vignettes:
vignette("reportable-shiny-application", package = "teal.reporter")
vignette("adding-support-for-reporting-to-custom-modules", package = "teal")
For more examples, please see the vignette "Using association plot" via
vignette("using-association-plot", package = "teal.modules.general").
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
CO2 <- CO2
factors <- names(Filter(isTRUE, vapply(CO2, is.factor, logical(1L))))
CO2[factors] <- lapply(CO2[factors], as.character)
})
app <- init(
data = data,
modules = modules(
tm_g_association(
ref = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(
choices = c("Plant", "Type", "Treatment"),
selected = "Plant"
)
),
vars = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(
choices = c("Plant", "Type", "Treatment"),
selected = "Treatment",
multiple = TRUE
)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
ADSL <- teal.data::rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_g_association(
ref = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2"),
selected = "RACE"
)
),
vars = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2"),
selected = "BMRKR2",
multiple = TRUE
)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.