| Type: | Package |
| Title: | General Modules for 'teal' Applications |
| Version: | 0.8.0 |
| Date: | 2026-07-31 |
| Description: | Prebuilt 'shiny' modules containing tools for viewing data, visualizing data, understanding missing and outlier values within your data and performing simple data analysis. This extends 'teal' framework that supports reproducible research and analysis. |
| License: | Apache License 2.0 |
| URL: | https://insightsengineering.github.io/teal.modules.general/, https://github.com/insightsengineering/teal.modules.general/ |
| BugReports: | https://github.com/insightsengineering/teal.modules.general/issues |
| Depends: | ggplot2 (≥ 3.5.0), R (≥ 4.1), shiny (≥ 1.8.1), teal (≥ 1.2.0), teal.picks (≥ 0.1.0), teal.transform (≥ 0.7.0) |
| Imports: | broom (≥ 0.7.10), bslib (≥ 0.8.0), checkmate (≥ 2.1.0), colourpicker (≥ 1.3.0), dplyr (≥ 1.1.0), DT (≥ 0.13), forcats (≥ 1.0.0), generics (≥ 0.1.3), ggExtra (≥ 0.10.1), ggpmisc (≥ 0.5.6), ggpp (≥ 0.5.8-1), ggrepel (≥ 0.9.6), goftest (≥ 1.2-3), grid, gridExtra (≥ 2.3), htmlwidgets (≥ 1.6.4), jsonlite (≥ 1.8.9), lattice, lifecycle (≥ 0.2.0), MASS (≥ 7.3-60), patchwork (≥ 1.2.0), rlang (≥ 1.1.0), rmarkdown (≥ 2.23), rtables (≥ 0.6.11), scales (≥ 1.3.0), shinyjs (≥ 2.1.0), shinyTree (≥ 0.2.8), shinyvalidate (≥ 0.1.3), shinyWidgets (≥ 0.5.1), sparkline (≥ 2.0), stats, stringr (≥ 1.4.1), teal.code (≥ 0.7.0), teal.data (≥ 0.8.0), teal.logger (≥ 0.4.0), teal.reporter (≥ 0.6.2), teal.widgets (≥ 0.5.2), tern (≥ 0.9.7), tibble (≥ 2.0.0), tidyr (≥ 0.8.3), tidyselect, tools, utils |
| Suggests: | gtsummary (≥ 2.5.0), knitr (≥ 1.42), logger (≥ 0.4.0), nestcolor (≥ 0.1.0), pkgload, roxy.shinylive, rvest, shinytest2, testthat (≥ 3.1.9), withr (≥ 2.0.0) |
| VignetteBuilder: | knitr, rmarkdown |
| Config/Needs/verdepcheck: | haleyjeppson/ggmosaic, tidyverse/ggplot2, rstudio/shiny, insightsengineering/teal, insightsengineering/teal.transform, mllg/checkmate, tidyverse/dplyr, rstudio/DT, tidyverse/forcats, r-lib/lifecycle, r-lib/scales, daattali/shinyjs, shinyTree/shinyTree, rstudio/shinyvalidate, dreamRs/shinyWidgets, tidyverse/stringr, insightsengineering/teal.code, insightsengineering/teal.data, insightsengineering/teal.logger, insightsengineering/teal.reporter, insightsengineering/teal.widgets, insightsengineering/tern, tidyverse/tibble, tidyverse/tidyr, daattali/colourpicker, daattali/ggExtra, aphalo/ggpmisc, aphalo/ggpp, slowkow/ggrepel, baddstats/goftest, ramnathv/htmlwidgets, jeroen/jsonlite, yihui/knitr, daroczig/logger, thomasp85/patchwork, insightsengineering/nestcolor, r-lib/pkgload, r-lib/rlang, rstudio/rmarkdown, insightsengineering/roxy.shinylive, insightsengineering/rtables, tidyverse/rvest, htmlwidgets/sparkline, rstudio/shinytest2, r-lib/testthat, r-lib/withr |
| Config/Needs/website: | insightsengineering/nesttemplate |
| Config/roxygen2/version: | 8.0.0 |
| Encoding: | UTF-8 |
| Language: | en-US |
| NeedsCompilation: | no |
| Packaged: | 2026-08-01 23:55:02 UTC; unardid |
| Author: | Dony Unardi [aut, cre], Dawid Kaledkowski [aut], Pawel Rucki [aut], Mahmoud Hallal [aut], Ondrej Slama [ctb], Maciej Nasinski [aut], Konrad Pagacz [aut], Nikolas Burkoff [aut], F. Hoffmann-La Roche AG [cph, fnd] |
| Maintainer: | Dony Unardi <unardid@gene.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-02 00:30:02 UTC |
teal.modules.general: General modules to add to a teal application
Description
The modules in this package are generic modules that should work with any data set (not necessarily for clinical trials data).
Author(s)
Maintainer: Dony Unardi unardid@gene.com
Authors:
Dony Unardi unardid@gene.com
Dawid Kaledkowski dawid.kaledkowski@roche.com
Pawel Rucki pawel.rucki@roche.com
Mahmoud Hallal mahmoud.hallal@roche.com
Maciej Nasinski
Konrad Pagacz
Nikolas Burkoff
Other contributors:
Ondrej Slama ondrej.slama@roche.com [contributor]
F. Hoffmann-La Roche AG [copyright holder, funder]
See Also
Useful links:
-
https://github.com/insightsengineering/teal.modules.general/
Report bugs at https://github.com/insightsengineering/teal.modules.general/issues
Add labels for facets to a ggplot2 object
Description
Enhances a ggplot2 plot by adding labels that describe
the faceting variables along the x and y axes.
Usage
add_facet_labels(p, xfacet_label = NULL, yfacet_label = NULL)
Arguments
p |
( |
xfacet_label |
( |
yfacet_label |
( |
Value
Returns grid or grob object (to be drawn with grid.draw)
Examples
library(ggplot2)
library(grid)
p <- ggplot(mtcars) +
aes(x = mpg, y = disp) +
geom_point() +
facet_grid(gear ~ cyl)
xfacet_label <- "cylinders"
yfacet_label <- "gear"
res <- add_facet_labels(p, xfacet_label, yfacet_label)
grid.newpage()
grid.draw(res)
grid.newpage()
grid.draw(add_facet_labels(p, xfacet_label = NULL, yfacet_label))
grid.newpage()
grid.draw(add_facet_labels(p, xfacet_label, yfacet_label = NULL))
grid.newpage()
grid.draw(add_facet_labels(p, xfacet_label = NULL, yfacet_label = NULL))
Mosaic Rectangles Layer for ggplot2
Description
Adds a mosaic-style rectangles layer to a ggplot, visualizing the
joint distribution of categorical variables.
Each rectangle's size reflects the proportion of observations for
combinations of x and fill.
Usage
geom_mosaic(
mapping = NULL,
data = NULL,
stat = "mosaic",
position = "identity",
...,
na.rm = FALSE,
show.legend = TRUE,
inherit.aes = TRUE
)
.calculate_coordinates(data)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. |
stat |
The statistical transformation to use on the data. Defaults to |
position |
Position adjustment. Defaults to |
... |
Other arguments passed to |
na.rm |
Logical. Should missing values be removed? |
show.legend |
Logical. Should this layer be included in the legends? |
inherit.aes |
Logical. If |
Value
A ggplot2 layer that adds mosaic rectangles to the plot.
Functions
-
.calculate_coordinates(): Computes the coordinates for rectangles in a mosaic plot based on combinations ofxandfillvariables. For each uniquexandfill, calculates the proportional widths and heights, stacking rectangles within eachxgroup.Value
A data frame with columns:
x,fill,xmin,xmax,ymin,ymax, representing the position and size of each rectangle.
Examples
df <- data.frame(RACE = c("Black", "White", "Black", "Asian"), SEX = c("M", "M", "F", "F"))
library(ggplot2)
ggplot(df) +
geom_mosaic(aes(x = RACE, fill = SEX))
Shared parameters documentation
Description
Defines common arguments shared across multiple functions in the package
to avoid repetition by using inheritParams.
Arguments
plot_height |
( |
plot_width |
( |
rotate_xaxis_labels |
( |
ggtheme |
( |
ggplot2_args |
( For more details see the vignette: |
basic_table_args |
( For more details see the vignette: |
pre_output |
( |
post_output |
( |
alpha |
(
|
size |
(
|
decorators |
|
table_datanames |
( |
Value
Object of class teal_module to be used in teal applications.
teal module: Principal component analysis
Description
Module conducts principal component analysis (PCA) on a given dataset and offers different ways of visualizing the outcomes, including elbow plot, circle plot, biplot, and eigenvector plot. Additionally, it enables dynamic customization of plot aesthetics, such as opacity, size, and font size, through UI inputs.
Usage
tm_a_pca(
label = "Principal Component Analysis",
dat = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(choices =
tidyselect::where(~is.numeric(.x) && all(!is.na(.x))), selected =
tidyselect::everything(), multiple = TRUE)),
plot_height = c(600, 200, 2000),
plot_width = NULL,
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
ggplot2_args = teal.widgets::ggplot2_args(),
rotate_xaxis_labels = FALSE,
font_size = c(12, 8, 20),
alpha = c(1, 0, 1),
size = c(2, 1, 8),
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()
)
Arguments
label |
( |
dat |
( |
plot_height |
( |
plot_width |
( |
ggtheme |
( |
ggplot2_args |
( List names should match the following: For more details see the vignette: |
rotate_xaxis_labels |
( |
font_size |
(
|
alpha |
(
|
size |
(
|
pre_output |
( |
post_output |
( |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
elbow_plot(ggplot) -
circle_plot(ggplot) -
biplot(ggplot) -
eigenvector_plot(ggplot)
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_a_pca(
..., # arguments for module
decorators = list(
elbow_plot = teal_transform_module(...), # applied to the `elbow_plot` output
circle_plot = teal_transform_module(...), # applied to the `circle_plot` output
biplot = teal_transform_module(...), # applied to the `biplot` output
eigenvector_plot = teal_transform_module(...) # applied to the `eigenvector_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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Examples
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
USArrests <- USArrests
})
app <- init(
data = data,
modules = modules(
tm_a_pca(
"PCA",
dat = teal.picks::picks(
datasets("USArrests"),
teal.picks::variables(
choices = c("Murder", "Assault", "UrbanPop", "Rape"),
selected = c("Murder", "Assault"),
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_a_pca(
dat = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = c("BMRKR1", "AGE", "EOSDY"),
selected = c("BMRKR1", "AGE"),
multiple = TRUE
)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Scatterplot and regression analysis
Description
Module for visualizing regression analysis, including scatterplots and various regression diagnostics plots. It allows users to explore the relationship between a set of regressors and a response variable, visualize residuals, and identify outliers.
Usage
tm_a_regression(
label = "Regression Analysis",
regressor = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(choices =
is.numeric, selected = tidyselect::last_col(), multiple = TRUE)),
response,
outlier,
plot_height = c(600, 200, 2000),
plot_width = NULL,
alpha = c(1, 0, 1),
size = c(2, 1, 8),
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
ggplot2_args = teal.widgets::ggplot2_args(),
pre_output = NULL,
post_output = NULL,
default_plot_type = 1,
default_outlier_label = "USUBJID",
label_segment_threshold = c(0.5, 0, 10),
transformators = list(),
decorators = list()
)
Arguments
label |
( |
regressor |
( |
response |
( |
outlier |
( |
plot_height |
( |
plot_width |
( |
alpha |
(
|
size |
(
|
ggtheme |
( |
ggplot2_args |
( List names should match the following: For more details see the vignette: |
pre_output |
( |
post_output |
( |
default_plot_type |
(
|
default_outlier_label |
( |
label_segment_threshold |
( It can take the following forms:
|
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
plot(ggplot)
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_a_regression(
..., # 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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Note
For more examples, please see the vignette "Using regression plots" via
vignette("using-regression-plots", package = "teal.modules.general").
Examples
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
CO2 <- CO2
})
app <- init(
data = data,
modules = modules(
tm_a_regression(
label = "Regression",
response = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(choices = "uptake", selected = "uptake")
),
regressor = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(choices = c("conc", "Treatment"), selected = "conc", 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_a_regression(
label = "Regression",
response = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(choices = "BMRKR1", selected = "BMRKR1")
),
regressor = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(choices = c("AGE", "SEX", "RACE"), selected = "AGE", multiple = TRUE)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Data table viewer
Description
Module provides a dynamic and interactive way to view data.frames in a teal application.
It uses the DT package to display data tables in a paginated, searchable, and sortable format,
which helps to enhance data exploration and analysis.
Usage
tm_data_table(
label = "Data Table",
variables_selected = list(),
datasets_selected = deprecated(),
datanames = if (missing(datasets_selected)) "all" else datasets_selected,
dt_args = list(),
dt_options = list(searching = FALSE, pageLength = 30, lengthMenu = c(5, 15, 30, 100),
scrollX = TRUE),
server_rendering = FALSE,
pre_output = NULL,
post_output = NULL,
transformators = list()
)
Arguments
label |
( |
variables_selected |
( |
datasets_selected |
( |
datanames |
(
|
dt_args |
( |
dt_options |
( |
server_rendering |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
Details
The DT package has an option DT.TOJSON_ARGS to show Inf and NA in data tables.
Configure the DT.TOJSON_ARGS option via
options(DT.TOJSON_ARGS = list(na = "string")) before running the module.
Note though that sorting of numeric columns with NA/Inf will be lexicographic not numerical.
Value
Object of class teal_module to be used in teal applications.
Examples in Shinylive
- example-1
- example-2
Examples
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
iris <- iris
})
app <- init(
data = data,
modules = modules(
tm_data_table(
variables_selected = list(
iris = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
),
dt_args = list(caption = "IRIS Table Caption")
)
)
)
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_data_table(
variables_selected = list(ADSL = c("STUDYID", "USUBJID", "SUBJID", "SITEID", "AGE", "SEX")),
dt_args = list(caption = "ADSL Table Caption")
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: File viewer
Description
The file viewer module provides a tool to view static files.
Supported formats include text formats, PDF, PNG APNG,
JPEG SVG, WEBP, GIF and BMP.
Usage
tm_file_viewer(
label = "File Viewer Module",
input_path = list(`Current Working Directory` = ".")
)
Arguments
label |
( |
input_path |
( Paths can be specified as absolute paths or relative to the running directory of the application. Default to the current working directory if not supplied. |
Value
Object of class teal_module to be used in teal applications.
Examples in Shinylive
- example-1
Examples
data <- teal_data()
data <- within(data, {
data <- data.frame(1)
})
app <- init(
data = data,
modules = modules(
tm_file_viewer(
input_path = list(
folder = system.file("sample_files", package = "teal.modules.general"),
png = system.file("sample_files/sample_file.png", package = "teal.modules.general"),
txt = system.file("sample_files/sample_file.txt", package = "teal.modules.general"),
url = file.path(
"https://www.fda.gov/files/drugs/published",
"Portable-Document-Format-Specifications.pdf"
)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Front page
Description
Creates a simple front page for teal applications, displaying
introductory text, tables, additional html or shiny tags, and footnotes.
Usage
tm_front_page(
label = "Front page",
header_text = character(0),
tables = list(),
additional_tags = tagList(),
footnotes = character(0),
show_metadata = deprecated(),
datanames = if (missing(show_metadata)) NULL else "all",
transformators = list()
)
Arguments
Value
Object of class teal_module to be used in teal applications.
Examples in Shinylive
- example-1
Examples
data <- teal_data()
data <- within(data, {
require(nestcolor)
ADSL <- teal.data::rADSL
attr(ADSL, "metadata") <- list("Author" = "NEST team", "data_source" = "synthetic data")
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
table_1 <- data.frame(Info = c("A", "B"), Text = c("A", "B"))
table_2 <- data.frame(`Column 1` = c("C", "D"), `Column 2` = c(5.5, 6.6), `Column 3` = c("A", "B"))
table_3 <- data.frame(Info = c("E", "F"), Text = c("G", "H"))
table_input <- list(
"Table 1" = table_1,
"Table 2" = table_2,
"Table 3" = table_3
)
app <- init(
data = data,
modules = modules(
tm_front_page(
header_text = c(
"Important information" = "It can go here.",
"Other information" = "Can go here."
),
tables = table_input,
additional_tags = HTML("Additional HTML or shiny tags go here <br>"),
footnotes = c("X" = "is the first footnote", "Y is the second footnote")
)
)
) |>
modify_header(tags$h1("Sample Application")) |>
modify_footer(tags$p("Application footer"))
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Stack plots of variables and show association with reference variable
Description
Module 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.
Usage
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()
)
Arguments
label |
( |
ref |
( |
vars |
( |
show_association |
( |
plot_height |
( |
plot_width |
( |
distribution_theme, association_theme |
( |
pre_output |
( |
post_output |
( |
ggplot2_args |
( List names should match the following: For more details see the vignette: |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
plot(grobcreated withggplot2::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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Note
For more examples, please see the vignette "Using association plot" via
vignette("using-association-plot", package = "teal.modules.general").
Examples
# 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)
}
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 = 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()),
y,
row_facet,
col_facet,
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,
transformators = list(),
decorators = list()
)
Arguments
label |
( |
x |
( |
y |
( |
row_facet |
( |
col_facet |
( |
facet |
( |
color |
( |
fill |
( |
size |
( |
use_density |
( |
color_settings |
( |
free_x_scales |
( |
free_y_scales |
( |
plot_height |
( |
plot_width |
( |
rotate_xaxis_labels |
( |
swap_axes |
( |
ggtheme |
( |
ggplot2_args |
( For more details see the vignette: |
pre_output |
( |
post_output |
( |
transformators |
( |
decorators |
|
Details
This is a general module to visualize 1 & 2 dimensional data.
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
plot(ggplot)
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_bivariate(
..., # 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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Note
For more examples, please see the vignette "Using bivariate plot" via
vignette("using-bivariate-plot", package = "teal.modules.general").
Examples
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
CO2 <- data.frame(CO2)
})
app <- init(
data = data,
modules = tm_g_bivariate(
label = "Bivariate Plots",
x = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(selected = "conc")
),
y = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(selected = "uptake")
),
row_facet = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(selected = "Type")
),
col_facet = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(selected = "Treatment")
)
)
)
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 = tm_g_bivariate(
label = "Bivariate Plots",
x = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(selected = "AGE")
),
y = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(selected = "SEX")
),
row_facet = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(selected = "ARM")
),
col_facet = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(selected = "COUNTRY")
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Distribution analysis
Description
Module is designed to explore the distribution of a single variable within a given dataset. It offers several tools, such as histograms, Q-Q plots, and various statistical tests to visually and statistically analyze the variable's distribution.
Usage
tm_g_distribution(
label = "Distribution Module",
dist_var = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(is.numeric),
teal.picks::values()),
strata_var = NULL,
group_var = NULL,
freq = FALSE,
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
ggplot2_args = teal.widgets::ggplot2_args(),
bins = c(30L, 1L, 100L),
plot_height = c(600, 200, 2000),
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()
)
Arguments
label |
( |
dist_var |
( |
strata_var |
( |
group_var |
( |
freq |
( |
ggtheme |
( |
ggplot2_args |
( List names should match the following: For more details see the vignette: |
bins |
(
|
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators::
-
histogram_plot(ggplot) -
qq_plot(ggplot) -
summary_table(DT::datatable) -
test_table(DT::datatable)
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_distribution(
..., # arguments for module
decorators = list(
histogram_plot = teal_transform_module(...), # applied only to `histogram_plot` output
qq_plot = teal_transform_module(...) # applied only to `qq_plot` output
summary_table = teal_transform_module(...) # applied only to `summary_table` output
test_table = teal_transform_module(...) # applied only to `test_table` 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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Examples
# general data example
data <- teal_data()
data <- within(data, {
iris <- iris
})
app <- init(
data = data,
modules = list(
tm_g_distribution(
dist_var = teal.picks::picks(
datasets("iris"),
teal.picks::variables(is.numeric),
teal.picks::values()
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC data example
data <- teal_data()
data <- within(data, {
ADSL <- teal.data::rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_g_distribution(
dist_var = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(c("BMRKR1", "AGE")),
values(multiple = FALSE)
),
strata_var = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(c("ARM", "COUNTRY", "SEX"), selected = NULL)
),
group_var = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(c("ARM", "COUNTRY", "SEX"), selected = NULL)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Response plot
Description
Generates a response plot for a given response and x variables.
This module allows users customize and add annotations to the plot depending
on the module's arguments.
It supports showing the counts grouped by other variable facets (by row / column),
swapping the coordinates, show count annotations and displaying the response plot
as frequency or density.
Usage
tm_g_response(
label = "Response Plot",
response = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(choices =
teal.picks::is_categorical(min.len = 2, max.len = 10)), teal.picks::values()),
x,
row_facet = NULL,
col_facet = NULL,
coord_flip = FALSE,
count_labels = TRUE,
rotate_xaxis_labels = FALSE,
freq = FALSE,
plot_height = c(600, 400, 5000),
plot_width = NULL,
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
ggplot2_args = teal.widgets::ggplot2_args(),
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()
)
Arguments
label |
( |
response |
( |
x |
( |
row_facet |
( |
col_facet |
( |
coord_flip |
( |
count_labels |
( |
rotate_xaxis_labels |
( |
freq |
( |
plot_height |
( |
plot_width |
( |
ggtheme |
( |
ggplot2_args |
( For more details see the vignette: |
pre_output |
( |
post_output |
( |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
plot(ggplot)
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_response(
..., # 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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Note
For more examples, please see the vignette "Using response plot" via
vignette("using-response-plot", package = "teal.modules.general").
Examples
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
mtcars <- mtcars
for (.v in c("cyl", "vs", "am", "gear")) {
mtcars[[.v]] <- as.factor(mtcars[[.v]])
}
})
app <- init(
data = data,
modules = modules(
tm_g_response(
label = "Response Plots",
response = teal.picks::picks(
teal.picks::datasets("mtcars"),
teal.picks::variables(
choices = c("cyl", "gear"),
selected = "cyl",
multiple = FALSE,
fixed = FALSE
),
teal.picks::values()
),
x = teal.picks::picks(
datasets("mtcars"),
teal.picks::variables(
choices = c("vs", "am"),
selected = "vs",
multiple = FALSE,
fixed = FALSE
),
teal.picks::values()
)
)
)
)
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_response(
label = "Response Plots",
response = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = c("BMRKR2", "COUNTRY"),
selected = "BMRKR2"
),
teal.picks::values()
),
x = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = c("SEX", "RACE"),
selected = "RACE"
),
teal.picks::values()
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
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 = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(is.numeric),
teal.picks::values()),
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(),
transformators = list(),
decorators = list()
)
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: |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
plot(ggplot)
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_scatterplot(
..., # 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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Note
For more examples, please see the vignette "Using scatterplot" via
vignette("using-scatterplot", package = "teal.modules.general").
Examples
# general data example
data <- teal_data()
data <- within(data, {
require(nestcolor)
CO2 <- CO2
})
app <- init(
data = data,
modules = modules(
tm_g_scatterplot(
label = "Scatterplot Choices",
x = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(
choices = c("conc", "uptake"),
selected = "conc"
),
teal.picks::values()
),
y = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(
choices = c("conc", "uptake"),
selected = "uptake"
),
teal.picks::values()
),
color_by = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(
choices = c("Plant", "Type", "Treatment", "conc", "uptake"),
selected = NULL
),
teal.picks::values()
),
size_by = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(choices = c("conc", "uptake"), selected = "uptake"),
teal.picks::values()
),
row_facet = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(
choices = c("Plant", "Type", "Treatment"),
selected = NULL
),
teal.picks::values()
),
col_facet = teal.picks::picks(
datasets("CO2"),
teal.picks::variables(choices = c("Plant", "Type", "Treatment"), selected = NULL),
teal.picks::values()
)
)
)
)
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_scatterplot(
label = "Scatterplot Choices",
x = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(choices = c("AGE", "BMRKR1", "BMRKR2"), selected = "AGE"),
teal.picks::values()
),
y = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(choices = c("AGE", "BMRKR1", "BMRKR2"), selected = "BMRKR1"),
teal.picks::values()
),
color_by = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(c("AGE", "BMRKR1", "BMRKR2", "RACE", "REGION1"), selected = NULL),
teal.picks::values()
),
size_by = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(choices = c("AGE", "BMRKR1"), selected = "AGE"),
teal.picks::values()
),
row_facet = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(choices = c("BMRKR2", "RACE", "REGION1"), selected = NULL),
teal.picks::values()
),
col_facet = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(choices = c("BMRKR2", "RACE", "REGION1"), selected = NULL),
teal.picks::values()
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Scatterplot matrix
Description
Generates a scatterplot matrix from selected variables from datasets.
Each plot within the matrix represents the relationship between two variables,
providing the overview of correlations and distributions across selected data.
Usage
tm_g_scatterplotmatrix(
label = "Scatterplot Matrix",
variables = list(teal.picks::picks(teal.picks::datasets(),
teal.picks::variables(selected = seq(1L, 5L), multiple = TRUE))),
min_n_variables = 2L,
max_n_variables = 5L,
plot_height = c(600, 200, 2000),
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()
)
Arguments
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
plot(ggplot- apatchworkassembled from individualggplotpanels)
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_scatterplotmatrix(
..., # 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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Note
For more examples, please see the vignette "Using scatterplot matrix" via
vignette("using-scatterplot-matrix", package = "teal.modules.general").
When Add Correlation is enabled, a simple Omit NAs checkbox
controls NA handling (checked = "pairwise.complete.obs", matching the
historical default). Unchecking it reveals a dropdown with all five
stats::cor() use options for advanced control.
Examples
# general data example
data <- teal_data()
data <- within(data, {
countries <- data.frame(
id = c("DE", "FR", "IT", "ES", "PT", "GR", "NL", "BE", "LU", "AT"),
government = factor(
c(2, 2, 2, 1, 2, 2, 1, 1, 1, 2),
labels = c("Monarchy", "Republic")
),
language_family = factor(
c(1, 3, 3, 3, 3, 2, 1, 1, 3, 1),
labels = c("Germanic", "Hellenic", "Romance")
),
population = c(83, 67, 60, 47, 10, 11, 17, 11, 0.6, 9),
area = c(357, 551, 301, 505, 92, 132, 41, 30, 2.6, 83),
gdp = c(3.4, 2.7, 2.1, 1.4, 0.3, 0.2, 0.7, 0.5, 0.1, 0.4),
debt = c(2.1, 2.3, 2.4, 2.6, 2.3, 2.4, 2.3, 2.4, 2.3, 2.4)
)
sales <- data.frame(
id = 1:50,
country_id = sample(
c("DE", "FR", "IT", "ES", "PT", "GR", "NL", "BE", "LU", "AT"),
size = 50,
replace = TRUE
),
year = sort(sample(2010:2020, 50, replace = TRUE)),
venue = sample(c("small", "medium", "large", "online"), 50, replace = TRUE),
cancelled = sample(c(TRUE, FALSE), 50, replace = TRUE),
quantity = rnorm(50, 100, 20),
costs = rnorm(50, 80, 20),
profit = rnorm(50, 20, 10)
)
})
join_keys(data) <- join_keys(
join_key("countries", "countries", "id"),
join_key("sales", "sales", "id"),
join_key("countries", "sales", c("id" = "country_id"))
)
app <- init(
data = data,
modules = modules(
tm_g_scatterplotmatrix(
label = "Scatterplot matrix",
variables = list(
teal.picks::picks(
datasets("countries"),
teal.picks::variables(
choices = tidyselect::everything(),
selected = c("area", "gdp", "debt"),
multiple = TRUE,
ordered = TRUE
),
teal.picks::values()
),
teal.picks::picks(
datasets("sales"),
teal.picks::variables(
choices = c("quantity", "costs", "profit"),
selected = c("quantity", "costs"),
multiple = TRUE,
ordered = TRUE
)
)
),
transformators = list(
teal_transform_filter(
teal.picks::picks(
datasets("sales"),
teal.picks::variables("country_id"),
teal.picks::values()
)
)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC data example
data <- teal_data()
data <- within(data, {
ADSL <- teal.data::rADSL
ADRS <- teal.data::rADRS
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_g_scatterplotmatrix(
label = "Scatterplot matrix",
variables = list(
teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = tidyselect::everything(),
selected = c("AGE", "RACE", "SEX"),
multiple = TRUE,
ordered = TRUE,
fixed = FALSE
),
teal.picks::values()
),
teal.picks::picks(
datasets("ADRS"),
teal.picks::variables(
choices = tidyselect::everything(),
selected = c("AVAL", "ADY"),
multiple = TRUE,
ordered = TRUE,
fixed = FALSE
)
)
),
transformators = list(
teal_transform_filter(
teal.picks::picks(
teal.picks::datasets("ADRS"),
teal.picks::variables("PARAMCD"),
teal.picks::values(selected = "BESRSPI")
)
)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Missing data analysis
Description
This module analyzes missing data in data.frames to help users explore missing observations and
gain insights into the completeness of their data.
It is useful for clinical data analysis within the context of CDISC standards and
adaptable for general data analysis purposes.
Usage
tm_missing_data(
label = "Missing data",
plot_height = c(600, 400, 5000),
plot_width = NULL,
datanames = "all",
parent_dataname = "ADSL",
ggtheme = c("classic", "gray", "bw", "linedraw", "light", "dark", "minimal", "void"),
ggplot2_args = list(`Combinations Hist` = teal.widgets::ggplot2_args(labs =
list(caption = NULL)), `Combinations Main` = teal.widgets::ggplot2_args(labs =
list(title = NULL))),
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()
)
Arguments
label |
( |
plot_height |
( |
plot_width |
( |
datanames |
(
|
parent_dataname |
( |
ggtheme |
( |
ggplot2_args |
( List names should match the following: For more details see the vignette: |
pre_output |
( |
post_output |
( |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
summary_plot(ggplot) -
combination_plot(grobcreated withggplot2::ggplotGrob()) -
by_variable_plot(ggplot) -
by_subject_plot(ggplot)
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_missing_data(
..., # arguments for module
decorators = list(
summary_plot = teal_transform_module(...), # applied only to `summary_plot` output
combination_plot = teal_transform_module(...), # applied only to `combination_plot` output
by_variable_plot = teal_transform_module(...) # applied only to `by_variable_plot` output
by_subject_plot = teal_transform_module(...) # applied only to `by_subject_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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Examples
# general example data
data <- teal_data()
data <- within(data, {
require(nestcolor)
add_nas <- function(x) {
x[sample(seq_along(x), floor(length(x) * runif(1, .05, .17)))] <- NA
x
}
iris <- iris
mtcars <- mtcars
iris[] <- lapply(iris, add_nas)
mtcars[] <- lapply(mtcars, add_nas)
mtcars[["cyl"]] <- as.factor(mtcars[["cyl"]])
mtcars[["gear"]] <- as.factor(mtcars[["gear"]])
})
app <- init(
data = data,
modules = modules(
tm_missing_data(parent_dataname = "mtcars")
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC example data
data <- teal_data()
data <- within(data, {
require(nestcolor)
ADSL <- teal.data::rADSL
ADRS <- rADRS
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_missing_data()
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Outliers analysis
Description
Module to analyze and identify outliers using different methods such as IQR, Z-score, and Percentiles, and offers visualizations including box plots, density plots, and cumulative distribution plots to help interpret the outliers.
Usage
tm_outliers(
label = "Outliers Module",
outlier_var = teal.picks::picks(teal.picks::datasets(),
teal.picks::variables(is.numeric, 1L, multiple = FALSE)),
categorical_var = teal.picks::picks(teal.picks::datasets(),
teal.picks::variables(choices = teal.picks::is_categorical(min.len = 1, max.len =
10), selected = 1L, multiple = TRUE)),
ggtheme = c("gray", "bw", "linedraw", "light", "dark", "minimal", "classic", "void"),
ggplot2_args = teal.widgets::ggplot2_args(),
plot_height = c(600, 200, 2000),
plot_width = NULL,
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()
)
Arguments
label |
( |
outlier_var |
( |
categorical_var |
( |
ggtheme |
( |
ggplot2_args |
( List names should match the following: For more details see the vignette: |
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
box_plot(ggplot) -
density_plot(ggplot) -
cumulative_plot(ggplot)
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_outliers(
..., # arguments for module
decorators = list(
box_plot = teal_transform_module(...), # applied only to `box_plot` output
density_plot = teal_transform_module(...), # applied only to `density_plot` output
cumulative_plot = teal_transform_module(...) # applied only to `cumulative_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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Examples
# general data example
data <- teal_data()
data <- within(data, CO2 <- CO2)
app <- init(
data = data,
modules = modules(
tm_outliers(
outlier_var = teal.picks::picks(
datasets("CO2", "CO2"),
teal.picks::variables(c("conc", "uptake"), "uptake"),
teal.picks::values()
),
categorical_var = teal.picks::picks(
datasets("CO2", "CO2"),
teal.picks::variables(c("Plant", "Type", "Treatment"), "Plant"),
teal.picks::values()
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC data example
data <- teal_data()
data <- within(data, {
ADSL <- teal.data::rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_outliers(
outlier_var = teal.picks::picks(
datasets("ADSL", "ADSL"),
teal.picks::variables(c("AGE", "BMRKR1"), "AGE")
),
categorical_var = teal.picks::picks(
datasets("ADSL", "ADSL"),
teal.picks::variables(teal.picks::is_categorical(min.len = 1, max.len = 10))
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: R Markdown render
Description
Module to render R Markdown files using the data provided in the
teal_data object.
The R Markdown file should be designed to accept variables available in the data names of the module.
Usage
tm_rmarkdown(
label = "RMarkdown Module",
rmd_content,
datanames = "all",
allow_download = TRUE,
pre_output = NULL,
post_output = NULL,
transformators = list(),
extra_transform = list()
)
Arguments
label |
( |
rmd_content |
( |
datanames |
(
|
allow_download |
( |
pre_output |
( |
post_output |
( |
transformators |
( |
extra_transform |
( |
Details
For example, if the teal_data object contains datasets named mtcars
and iris, the R Markdown file can use these as variables as they
will be available in the R Markdown environment.
The libraries used in the R Markdown file must be available in the deployed shiny app environment.
When developing the R Markdown file, the working data can be simulated
on a code chunk, which in turn can look for the presence of .raw_data
object to determine if it is being run inside the teal module or not.
Example R markdown file:
---
title: "R Markdown Report"
output: html_document
---
```{r eval=!exists(".raw_data")}
mtcars <- datasets::mtcars
iris <- datasets::iris
```
```{r}
summary(mtcars) |> print()
summary(iris) |> print()
```
Value
Object of class teal_module to be used in teal applications.
Reporting
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")
Examples in Shinylive
- example-1
Examples
# general data example
data <- teal_data()
data <- within(data, {
CO2 <- CO2
})
app <- init(
data = data,
modules = modules(
tm_rmarkdown(
label = "RMarkdown Module",
rmd_content = c(
"---",
"title: \"R Markdown Report\"",
"output: html_document",
"---",
"",
"```{r}",
"summary(CO2) |> print()",
"```"
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
nrow_transform <- teal_transform_module(
label = "N Rows selector",
ui = function(id) {
ns <- NS(id)
tags$div(
numericInput(ns("n_rows"), "Show n rows", value = 40, min = 0, max = 200, step = 5)
)
},
server = function(id, data) {
moduleServer(id, function(input, output, session) {
reactive({
req(data())
within(data(),
{
n_rows <- n_rows_value
},
n_rows_value = input$n_rows
)
})
})
}
)
app <- init(
data = data,
modules = modules(
tm_rmarkdown(
label = "RMarkdown Module",
rmd_content = readLines(
system.file(
file.path("sample_files", "co2_example.Rmd"),
package = "teal.modules.general"
)
),
allow_download = FALSE,
extra_transform = list(nrow_transform)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Cross-table
Description
Generates a simple cross-table of two variables from a dataset with custom options for showing percentages and sub-totals.
Usage
tm_t_crosstable(
label = "Cross Table",
x = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(choices =
teal.picks::is_categorical(min.len = 2, max.len = 10), selected = 1L, multiple =
TRUE, ordered = TRUE)),
y,
show_percentage = TRUE,
show_total = TRUE,
remove_zero_columns = FALSE,
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args(),
transformators = list(),
decorators = list()
)
Arguments
label |
( |
x |
( |
y |
(
|
show_percentage |
( |
show_total |
( |
remove_zero_columns |
( |
pre_output |
( |
post_output |
( |
basic_table_args |
( For more details see the vignette: |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Table Settings
The module provides several table settings that can be adjusted:
-
Show column percentage: Shows column percentages when enabled -
Show total column: Shows a total column when enabled -
Remove zero-only columns: Removes columns that contain only zeros from the output table
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
table(ElementaryTable- output ofrtables::build_table)
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_t_crosstable(
..., # arguments for module
decorators = list(
table = teal_transform_module(...) # applied to the `table` 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.
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Note
For more examples, please see the vignette "Using cross table" via
vignette("using-cross-table", package = "teal.modules.general").
Examples
# general data example
data <- teal_data()
data <- within(data, {
mtcars <- mtcars
for (v in c("cyl", "vs", "am", "gear")) {
mtcars[[v]] <- as.factor(mtcars[[v]])
}
mtcars[["primary_key"]] <- seq_len(nrow(mtcars))
})
join_keys(data) <- join_keys(join_key("mtcars", "mtcars", "primary_key"))
app <- init(
data = data,
modules = modules(
tm_t_crosstable(
label = "Cross Table",
x = teal.picks::picks(
datasets("mtcars"),
teal.picks::variables(
choices = variable_choices(data[["mtcars"]], c("cyl", "vs", "am", "gear")),
selected = c("cyl", "gear"),
multiple = TRUE,
ordered = TRUE,
fixed = FALSE
),
teal.picks::values()
),
y = teal.picks::picks(
datasets("mtcars"),
teal.picks::variables(
choices = variable_choices(data[["mtcars"]], c("cyl", "vs", "am", "gear")),
selected = "vs",
multiple = FALSE,
fixed = FALSE
),
teal.picks::values()
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC data example
data <- teal_data()
data <- within(data, {
ADSL <- teal.data::rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_t_crosstable(
label = "Cross Table",
x = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = variable_choices(data[["ADSL"]], subset = function(data) {
idx <- !vapply(data, inherits, logical(1), c("Date", "POSIXct", "POSIXlt"))
return(names(data)[idx])
}),
selected = "COUNTRY",
multiple = TRUE,
ordered = TRUE,
fixed = FALSE
),
teal.picks::values()
),
y = teal.picks::picks(
datasets("ADSL"),
teal.picks::variables(
choices = variable_choices(data[["ADSL"]], subset = function(data) {
idx <- vapply(data, is.factor, logical(1))
return(names(data)[idx])
}),
selected = "SEX",
multiple = FALSE,
fixed = FALSE
),
teal.picks::values()
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: GT Summary table
Description
Summary table from a given dataset, using gtsummary.
Usage
tm_tbl_summary(
label = "Summary table",
by = NULL,
include = teal.picks::picks(teal.picks::datasets(), teal.picks::variables(selected =
dplyr::everything(), multiple = TRUE)),
dataname = NULL,
...,
col_label = NULL,
pre_output = NULL,
post_output = NULL,
transformators = list(),
decorators = list()
)
Arguments
label |
( |
by |
( |
include |
( |
dataname |
( |
... |
Arguments passed on to
|
col_label |
Used to override default labels in summary table, e.g. |
pre_output |
( |
post_output |
( |
transformators |
( |
decorators |
|
Value
Object of class teal_module to be used in teal applications.
Decorating Module
This module generates the following objects, which can be modified in place using decorators:
-
table(gtsummary- output ofgtsummary::tbl_summary())
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_tbl_summary(
..., # arguments for module
decorators = list(
table = teal_transform_module(...) # applied to the `table` 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.
statistic argument
The statistic argument specifies the statistics presented in the table. The
input dictates the summary statistics presented in the table. For example,
statistic = list(age ~ "{mean} ({sd})") would report the mean and
standard deviation for age; statistic = list(all_continuous() ~ "{mean} ({sd})")
would report the mean and standard deviation for all continuous variables.
The values are interpreted using glue::glue() syntax:
a name that appears between curly brackets will be interpreted as a function
name and the formatted result of that function will be placed in the table.
For categorical variables, the following statistics are available to display:
{n} (frequency), {N} (denominator), {p} (percent).
For continuous variables, any univariate function may be used.
The most commonly used functions are {median}, {mean}, {sd}, {min},
and {max}.
Additionally, {p##} is available for percentiles, where ## is an integer from 0 to 100.
For example, p25: quantile(probs=0.25, type=2).
When the summary type is "continuous2", pass a vector of statistics.
Each element of the vector will result in a separate row in the summary table.
For both categorical and continuous variables, statistics on the number of missing and non-missing observations and their proportions are available to display.
-
{N_obs}total number of observations -
{N_miss}number of missing observations -
{N_nonmiss}number of non-missing observations -
{p_miss}percentage of observations missing -
{p_nonmiss}percentage of observations not missing
digits argument
The digits argument specifies the the number of digits (or formatting function) statistics are rounded to.
The values passed can either be a single integer, a vector of integers, a
function, or a list of functions. If a single integer or function is passed,
it is recycled to the length of the number of statistics presented.
For example, if the statistic is "{mean} ({sd})", it is equivalent to
pass 1, c(1, 1), label_style_number(digits=1), and
list(label_style_number(digits=1), label_style_number(digits=1)).
Named lists are also accepted to change the default formatting for a single
statistic, e.g. list(sd = label_style_number(digits=1)).
type and value arguments
There are four summary types. Use the type argument to change the default summary types.
-
"continuous"summaries are shown on a single row. Most numeric variables default to summary type continuous. -
"continuous2"summaries are shown on 2 or more rows -
"categorical"multi-line summaries of nominal data. Character variables, factor variables, and numeric variables with fewer than 10 unique levels default to type categorical. To change a numeric variable to continuous that defaulted to categorical, usetype = list(varname ~ "continuous") -
"dichotomous"categorical variables that are displayed on a single row, rather than one row per level of the variable. Variables coded asTRUE/FALSE,0/1, oryes/noare assumed to be dichotomous, and theTRUE,1, andyesrows are displayed. Otherwise, the value to display must be specified in thevalueargument, e.g.value = list(varname ~ "level to show")
Reporting
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")
Examples in Shinylive
- example-1
- example-2
Examples
# General example
data <- teal_data()
data <- within(data, CO2 <- CO2)
app <- init(
data = data,
modules = modules(
tm_tbl_summary(
by = teal.picks::picks(
datasets("CO2", "CO2"),
variables(selected = "Plant")
),
include = teal.picks::picks(
datasets("CO2", "CO2"),
variables(selected = c("Type", "Treatment"), multiple = TRUE)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC data example
data <- within(teal.data::teal_data(), {
ADSL <- teal.data::rADSL
ADTTE <- teal.data::rADTTE
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_tbl_summary(
by = teal.picks::picks(
datasets(c("ADSL", "ADTTE"), "ADTTE"),
variables(c("SEX", "COUNTRY", "SITEID", "ACTARM", "CNSR", "PARAMCD"), "SEX")
),
include = teal.picks::picks(
datasets(c("ADSL", "ADTTE"), "ADSL"),
variables(c("SITEID", "COUNTRY", "ACTARM", "SEX"), "SITEID", multiple = TRUE)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
teal module: Variable browser
Description
Module provides provides a detailed summary and visualization of variable distributions
for data.frame objects, with interactive features to customize analysis.
Usage
tm_variable_browser(
label = "Variable Browser",
datasets_selected = deprecated(),
datanames = if (missing(datasets_selected)) "all" else datasets_selected,
parent_dataname = "ADSL",
pre_output = NULL,
post_output = NULL,
ggplot2_args = teal.widgets::ggplot2_args(),
transformators = list()
)
Arguments
label |
( |
datasets_selected |
( |
datanames |
(
|
parent_dataname |
( |
pre_output |
( |
post_output |
( |
ggplot2_args |
( For more details see the vignette: |
transformators |
( |
Details
Numeric columns with fewer than 30 distinct values can be treated as either discrete or continuous with a checkbox allowing users to switch how they are treated(if < 6 unique values then the default is discrete, otherwise it is continuous).
Value
Object of class teal_module to be used in teal applications.
Examples in Shinylive
- example-1
- example-2
Examples
# general data example
data <- teal_data()
data <- within(data, {
iris <- iris
mtcars <- mtcars
women <- women
faithful <- faithful
CO2 <- CO2
})
app <- init(
data = data,
modules = modules(
tm_variable_browser(
label = "Variable browser"
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
# CDISC example data
library(sparkline)
data <- teal_data()
data <- within(data, {
ADSL <- teal.data::rADSL
ADTTE <- teal.data::rADTTE
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
app <- init(
data = data,
modules = modules(
tm_variable_browser(
label = "Variable browser"
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}