Title: | General Modules for 'teal' Applications |
---|---|
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. |
Authors: | Dawid Kaledkowski [aut, cre], 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: | Dawid Kaledkowski <[email protected]> |
License: | Apache License 2.0 |
Version: | 0.3.0.9054 |
Built: | 2024-11-08 14:29:39 UTC |
Source: | https://github.com/insightsengineering/teal.modules.general |
ggplot2
objectEnhances a ggplot2
plot by adding labels that describe
the faceting variables along the x and y axes.
add_facet_labels(p, xfacet_label = NULL, yfacet_label = NULL)
add_facet_labels(p, xfacet_label = NULL, yfacet_label = NULL)
p |
( |
xfacet_label |
( |
yfacet_label |
( |
Returns grid
or grob
object (to be drawn with grid.draw
)
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))
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))
Uses stats::cor.test()
per default for all numerical input variables and converts results
to character vector.
Could be extended if different stats for different variable types are needed.
Meant to be called from lattice::panel.text()
.
get_scatterplotmatrix_stats( x, y, .f = stats::cor.test, .f_args = list(), round_stat = 2, round_pval = 4 )
get_scatterplotmatrix_stats( x, y, .f = stats::cor.test, .f_args = list(), round_stat = 2, round_pval = 4 )
x , y
|
( |
.f |
( |
.f_args |
( |
round_stat |
( |
round_pval |
( |
Presently we need to use a formula input for stats::cor.test
because
na.fail
only gets evaluated when a formula is passed (see below).
x = c(1,3,5,7,NA) y = c(3,6,7,8,1) stats::cor.test(x, y, na.action = "na.fail") stats::cor.test(~ x + y, na.action = "na.fail")
Character with stats. For stats::cor.test()
correlation coefficient and p-value.
set.seed(1) x <- runif(25, 0, 1) y <- runif(25, 0, 1) x[c(3, 10, 18)] <- NA get_scatterplotmatrix_stats(x, y, .f = stats::cor.test, .f_args = list(method = "pearson")) get_scatterplotmatrix_stats(x, y, .f = stats::cor.test, .f_args = list( method = "pearson", na.action = na.fail ))
set.seed(1) x <- runif(25, 0, 1) y <- runif(25, 0, 1) x[c(3, 10, 18)] <- NA get_scatterplotmatrix_stats(x, y, .f = stats::cor.test, .f_args = list(method = "pearson")) get_scatterplotmatrix_stats(x, y, .f = stats::cor.test, .f_args = list( method = "pearson", na.action = na.fail ))
teal
module: Principal component analysisModule 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.
tm_a_pca( label = "Principal Component Analysis", dat, 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 )
tm_a_pca( label = "Principal Component Analysis", dat, 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 )
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 |
( |
Object of class teal_module
to be used in teal
applications.
# general data example data <- teal_data() data <- within(data, { require(nestcolor) USArrests <- USArrests }) app <- init( data = data, modules = modules( tm_a_pca( "PCA", dat = data_extract_spec( dataname = "USArrests", select = select_spec( choices = variable_choices( data = data[["USArrests"]], c("Murder", "Assault", "UrbanPop", "Rape") ), selected = c("Murder", "Assault"), multiple = TRUE ), filter = NULL ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_a_pca( "PCA", dat = data_extract_spec( dataname = "ADSL", select = select_spec( choices = variable_choices( data = data[["ADSL"]], c("BMRKR1", "AGE", "EOSDY") ), selected = c("BMRKR1", "AGE"), multiple = TRUE ), filter = NULL ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# general data example data <- teal_data() data <- within(data, { require(nestcolor) USArrests <- USArrests }) app <- init( data = data, modules = modules( tm_a_pca( "PCA", dat = data_extract_spec( dataname = "USArrests", select = select_spec( choices = variable_choices( data = data[["USArrests"]], c("Murder", "Assault", "UrbanPop", "Rape") ), selected = c("Murder", "Assault"), multiple = TRUE ), filter = NULL ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_a_pca( "PCA", dat = data_extract_spec( dataname = "ADSL", select = select_spec( choices = variable_choices( data = data[["ADSL"]], c("BMRKR1", "AGE", "EOSDY") ), selected = c("BMRKR1", "AGE"), multiple = TRUE ), filter = NULL ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Scatterplot and regression analysisModule 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.
tm_a_regression( label = "Regression Analysis", regressor, response, 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) )
tm_a_regression( label = "Regression Analysis", regressor, response, 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) )
label |
( |
regressor |
( |
response |
( |
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:
|
Object of class teal_module
to be used in teal
applications.
For more examples, please see the vignette "Using regression plots" via
vignette("using-regression-plots", package = "teal.modules.general")
.
# 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 = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variable:", choices = "uptake", selected = "uptake", multiple = FALSE, fixed = TRUE ) ), regressor = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variables:", choices = variable_choices(data[["CO2"]], c("conc", "Treatment")), selected = "conc", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_a_regression( label = "Regression", response = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = "BMRKR1", selected = "BMRKR1", multiple = FALSE, fixed = TRUE ) ), regressor = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", choices = variable_choices(data[["ADSL"]], c("AGE", "SEX", "RACE")), selected = "AGE", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# 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 = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variable:", choices = "uptake", selected = "uptake", multiple = FALSE, fixed = TRUE ) ), regressor = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variables:", choices = variable_choices(data[["CO2"]], c("conc", "Treatment")), selected = "conc", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_a_regression( label = "Regression", response = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = "BMRKR1", selected = "BMRKR1", multiple = FALSE, fixed = TRUE ) ), regressor = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", choices = variable_choices(data[["ADSL"]], c("AGE", "SEX", "RACE")), selected = "AGE", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Data table viewerModule provides a dynamic and interactive way to view data.frame
s 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.
tm_data_table( label = "Data Table", variables_selected = list(), datasets_selected = character(0), 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 )
tm_data_table( label = "Data Table", variables_selected = list(), datasets_selected = character(0), 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 )
label |
( |
variables_selected |
( |
datasets_selected |
( |
dt_args |
( |
dt_options |
( |
server_rendering |
( |
pre_output |
( |
post_output |
( |
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.
Object of class teal_module
to be used in teal
applications.
# 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 <- 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) }
# 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 <- 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 viewerThe file viewer module provides a tool to view static files.
Supported formats include text formats, PDF
, PNG
APNG
,
JPEG
SVG
, WEBP
, GIF
and BMP
.
tm_file_viewer( label = "File Viewer Module", input_path = list(`Current Working Directory` = ".") )
tm_file_viewer( label = "File Viewer Module", input_path = list(`Current Working Directory` = ".") )
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. |
Object of class teal_module
to be used in teal
applications.
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 = "https://fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf" ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
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 = "https://fda.gov/files/drugs/published/Portable-Document-Format-Specifications.pdf" ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Front pageCreates a simple front page for teal
applications, displaying
introductory text, tables, additional html
or shiny
tags, and footnotes.
tm_front_page( label = "Front page", header_text = character(0), tables = list(), additional_tags = tagList(), footnotes = character(0), show_metadata = FALSE )
tm_front_page( label = "Front page", header_text = character(0), tables = list(), additional_tags = tagList(), footnotes = character(0), show_metadata = FALSE )
label |
( |
header_text |
( |
tables |
( |
additional_tags |
( |
footnotes |
( |
show_metadata |
( |
Object of class teal_module
to be used in teal
applications.
data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- 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"), show_metadata = TRUE ) ), header = tags$h1("Sample Application"), footer = tags$p("Application footer"), ) if (interactive()) { shinyApp(app$ui, app$server) }
data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- 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"), show_metadata = TRUE ) ), header = tags$h1("Sample Application"), footer = tags$p("Application footer"), ) if (interactive()) { shinyApp(app$ui, app$server) }
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, 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() )
tm_g_association( label = "Association", ref, 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() )
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: |
Object of class teal_module
to be used in teal
applications.
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 = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variable:", choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")), selected = "Plant", fixed = FALSE ) ), vars = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variables:", choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")), selected = "Treatment", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_association( ref = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = variable_choices( data[["ADSL"]], c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2") ), selected = "RACE", fixed = FALSE ) ), vars = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", choices = variable_choices( data[["ADSL"]], c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2") ), selected = "BMRKR2", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# 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 = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variable:", choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")), selected = "Plant", fixed = FALSE ) ), vars = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variables:", choices = variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment")), selected = "Treatment", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_association( ref = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = variable_choices( data[["ADSL"]], c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2") ), selected = "RACE", fixed = FALSE ) ), vars = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", choices = variable_choices( data[["ADSL"]], c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2") ), selected = "BMRKR2", multiple = TRUE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Univariate and bivariate visualizationsModule enables the creation of univariate and bivariate plots, facilitating the exploration of data distributions and relationships between two variables.
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 )
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 )
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 |
( |
This is a general module to visualize 1 & 2 dimensional data.
Object of class teal_module
to be used in teal
applications.
For more examples, please see the vignette "Using bivariate plot" via
vignette("using-bivariate-plot", package = "teal.modules.general")
.
# general data example data <- teal_data() data <- within(data, { require(nestcolor) CO2 <- data.frame(CO2) }) app <- init( data = data, 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 ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, 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 ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# general data example data <- teal_data() data <- within(data, { require(nestcolor) CO2 <- data.frame(CO2) }) app <- init( data = data, 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 ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, 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 ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Distribution analysisModule 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.
tm_g_distribution( label = "Distribution Module", dist_var, 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 )
tm_g_distribution( label = "Distribution Module", dist_var, 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 )
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 |
( |
Object of class teal_module
to be used in teal
applications.
# general data example data <- teal_data() data <- within(data, { iris <- iris }) app <- init( data = data, modules = list( tm_g_distribution( dist_var = data_extract_spec( dataname = "iris", select = select_spec(variable_choices("iris"), "Petal.Length") ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] vars1 <- choices_selected( variable_choices(data[["ADSL"]], c("ARM", "COUNTRY", "SEX")), selected = NULL ) app <- init( data = data, modules = modules( tm_g_distribution( dist_var = data_extract_spec( dataname = "ADSL", select = select_spec( choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE ) ), strata_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ), group_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# general data example data <- teal_data() data <- within(data, { iris <- iris }) app <- init( data = data, modules = list( tm_g_distribution( dist_var = data_extract_spec( dataname = "iris", select = select_spec(variable_choices("iris"), "Petal.Length") ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] vars1 <- choices_selected( variable_choices(data[["ADSL"]], c("ARM", "COUNTRY", "SEX")), selected = NULL ) app <- init( data = data, modules = modules( tm_g_distribution( dist_var = data_extract_spec( dataname = "ADSL", select = select_spec( choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")), selected = "BMRKR1", multiple = FALSE, fixed = FALSE ) ), strata_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ), group_var = data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars1, multiple = TRUE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Response plotGenerates 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.
tm_g_response( label = "Response Plot", response, 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 )
tm_g_response( label = "Response Plot", response, 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 )
label |
( |
response |
( The |
x |
( The |
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 |
( |
Object of class teal_module
to be used in teal
applications.
For more examples, please see the vignette "Using response plot" via
vignette("using-response-plot", package = "teal.modules.general")
.
# 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 = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("cyl", "gear")), selected = "cyl", multiple = FALSE, fixed = FALSE ) ), x = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("vs", "am")), selected = "vs", multiple = FALSE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_response( label = "Response Plots", response = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = variable_choices(data[["ADSL"]], c("BMRKR2", "COUNTRY")), selected = "BMRKR2", multiple = FALSE, fixed = FALSE ) ), x = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = variable_choices(data[["ADSL"]], c("SEX", "RACE")), selected = "RACE", multiple = FALSE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# 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 = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("cyl", "gear")), selected = "cyl", multiple = FALSE, fixed = FALSE ) ), x = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("vs", "am")), selected = "vs", multiple = FALSE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_response( label = "Response Plots", response = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = variable_choices(data[["ADSL"]], c("BMRKR2", "COUNTRY")), selected = "BMRKR2", multiple = FALSE, fixed = FALSE ) ), x = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", choices = variable_choices(data[["ADSL"]], c("SEX", "RACE")), selected = "RACE", multiple = FALSE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: ScatterplotGenerates 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.
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() )
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() )
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: |
Object of class teal_module
to be used in teal
applications.
For more examples, please see the vignette "Using scatterplot" via
vignette("using-scatterplot", package = "teal.modules.general")
.
# 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 = 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 ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(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 ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# 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 = 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 ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(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 ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Scatterplot matrixGenerates 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.
tm_g_scatterplotmatrix( label = "Scatterplot Matrix", variables, plot_height = c(600, 200, 2000), plot_width = NULL, pre_output = NULL, post_output = NULL )
tm_g_scatterplotmatrix( label = "Scatterplot Matrix", variables, plot_height = c(600, 200, 2000), plot_width = NULL, pre_output = NULL, post_output = NULL )
label |
( |
variables |
( |
plot_height |
( |
plot_width |
( |
pre_output |
( |
post_output |
( |
Object of class teal_module
to be used in teal
applications.
For more examples, please see the vignette "Using scatterplot matrix" via
vignette("using-scatterplot-matrix", package = "teal.modules.general")
.
# 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( data_extract_spec( dataname = "countries", select = select_spec( label = "Select variables:", choices = variable_choices(data[["countries"]]), selected = c("area", "gdp", "debt"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ), data_extract_spec( dataname = "sales", filter = filter_spec( label = "Select variable:", vars = "country_id", choices = value_choices(data[["sales"]], "country_id"), selected = c("DE", "FR", "IT", "ES", "PT", "GR", "NL", "BE", "LU", "AT"), multiple = TRUE ), select = select_spec( label = "Select variables:", choices = variable_choices(data[["sales"]], c("quantity", "costs", "profit")), selected = c("quantity", "costs", "profit"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL ADRS <- rADRS }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_scatterplotmatrix( label = "Scatterplot matrix", variables = list( data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", choices = variable_choices(data[["ADSL"]]), selected = c("AGE", "RACE", "SEX"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ), data_extract_spec( dataname = "ADRS", filter = filter_spec( label = "Select endpoints:", vars = c("PARAMCD", "AVISIT"), choices = value_choices(data[["ADRS"]], c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), selected = "INVET - END OF INDUCTION", multiple = TRUE ), select = select_spec( label = "Select variables:", choices = variable_choices(data[["ADRS"]]), selected = c("AGE", "AVAL", "ADY"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# 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( data_extract_spec( dataname = "countries", select = select_spec( label = "Select variables:", choices = variable_choices(data[["countries"]]), selected = c("area", "gdp", "debt"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ), data_extract_spec( dataname = "sales", filter = filter_spec( label = "Select variable:", vars = "country_id", choices = value_choices(data[["sales"]], "country_id"), selected = c("DE", "FR", "IT", "ES", "PT", "GR", "NL", "BE", "LU", "AT"), multiple = TRUE ), select = select_spec( label = "Select variables:", choices = variable_choices(data[["sales"]], c("quantity", "costs", "profit")), selected = c("quantity", "costs", "profit"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL ADRS <- rADRS }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_g_scatterplotmatrix( label = "Scatterplot matrix", variables = list( data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variables:", choices = variable_choices(data[["ADSL"]]), selected = c("AGE", "RACE", "SEX"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ), data_extract_spec( dataname = "ADRS", filter = filter_spec( label = "Select endpoints:", vars = c("PARAMCD", "AVISIT"), choices = value_choices(data[["ADRS"]], c("PARAMCD", "AVISIT"), c("PARAM", "AVISIT")), selected = "INVET - END OF INDUCTION", multiple = TRUE ), select = select_spec( label = "Select variables:", choices = variable_choices(data[["ADRS"]]), selected = c("AGE", "AVAL", "ADY"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Missing data analysisThis module analyzes missing data in data.frame
s 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.
tm_missing_data( label = "Missing data", plot_height = c(600, 400, 5000), plot_width = NULL, 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 )
tm_missing_data( label = "Missing data", plot_height = c(600, 400, 5000), plot_width = NULL, 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 )
label |
( |
plot_height |
( |
plot_width |
( |
parent_dataname |
( |
ggtheme |
( |
ggplot2_args |
( List names should match the following: For more details see the vignette: |
pre_output |
( |
post_output |
( |
Object of class teal_module
to be used in teal
applications.
# 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() ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC example data data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- 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) }
# 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() ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC example data data <- teal_data() data <- within(data, { require(nestcolor) ADSL <- 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 analysisModule 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.
tm_outliers( label = "Outliers Module", outlier_var, categorical_var = NULL, 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 )
tm_outliers( label = "Outliers Module", outlier_var, categorical_var = NULL, 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 )
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 |
( |
Object of class teal_module
to be used in teal
applications.
# general data example data <- teal_data() data <- within(data, { CO2 <- CO2 CO2[["primary_key"]] <- seq_len(nrow(CO2)) }) join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key")) vars <- choices_selected(variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment"))) app <- init( data = data, modules = modules( tm_outliers( outlier_var = list( 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 ) ) ), categorical_var = list( data_extract_spec( dataname = "CO2", filter = filter_spec( vars = vars, choices = value_choices(data[["CO2"]], vars$selected), selected = value_choices(data[["CO2"]], vars$selected), multiple = TRUE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] fact_vars_adsl <- names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor))) vars <- choices_selected(variable_choices(data[["ADSL"]], fact_vars_adsl)) app <- init( data = data, modules = modules( tm_outliers( outlier_var = list( 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 ) ) ), categorical_var = list( data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars, choices = value_choices(data[["ADSL"]], vars$selected), selected = value_choices(data[["ADSL"]], vars$selected), multiple = TRUE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# general data example data <- teal_data() data <- within(data, { CO2 <- CO2 CO2[["primary_key"]] <- seq_len(nrow(CO2)) }) join_keys(data) <- join_keys(join_key("CO2", "CO2", "primary_key")) vars <- choices_selected(variable_choices(data[["CO2"]], c("Plant", "Type", "Treatment"))) app <- init( data = data, modules = modules( tm_outliers( outlier_var = list( 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 ) ) ), categorical_var = list( data_extract_spec( dataname = "CO2", filter = filter_spec( vars = vars, choices = value_choices(data[["CO2"]], vars$selected), selected = value_choices(data[["CO2"]], vars$selected), multiple = TRUE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] fact_vars_adsl <- names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor))) vars <- choices_selected(variable_choices(data[["ADSL"]], fact_vars_adsl)) app <- init( data = data, modules = modules( tm_outliers( outlier_var = list( 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 ) ) ), categorical_var = list( data_extract_spec( dataname = "ADSL", filter = filter_spec( vars = vars, choices = value_choices(data[["ADSL"]], vars$selected), selected = value_choices(data[["ADSL"]], vars$selected), multiple = TRUE ) ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Cross-tableGenerates a simple cross-table of two variables from a dataset with custom options for showing percentages and sub-totals.
tm_t_crosstable( label = "Cross Table", x, y, show_percentage = TRUE, show_total = TRUE, pre_output = NULL, post_output = NULL, basic_table_args = teal.widgets::basic_table_args() )
tm_t_crosstable( label = "Cross Table", x, y, show_percentage = TRUE, show_total = TRUE, pre_output = NULL, post_output = NULL, basic_table_args = teal.widgets::basic_table_args() )
label |
( |
x |
( |
y |
(
|
show_percentage |
( |
show_total |
( |
pre_output |
( |
post_output |
( |
basic_table_args |
( For more details see the vignette: |
Object of class teal_module
to be used in teal
applications.
For more examples, please see the vignette "Using cross table" via
vignette("using-cross-table", package = "teal.modules.general")
.
# 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 = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("cyl", "vs", "am", "gear")), selected = c("cyl", "gear"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ), y = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("cyl", "vs", "am", "gear")), selected = "vs", multiple = FALSE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_t_crosstable( label = "Cross Table", x = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", 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 ) ), y = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", 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 ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
# 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 = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("cyl", "vs", "am", "gear")), selected = c("cyl", "gear"), multiple = TRUE, ordered = TRUE, fixed = FALSE ) ), y = data_extract_spec( dataname = "mtcars", select = select_spec( label = "Select variable:", choices = variable_choices(data[["mtcars"]], c("cyl", "vs", "am", "gear")), selected = "vs", multiple = FALSE, fixed = FALSE ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) } # CDISC data example data <- teal_data() data <- within(data, { ADSL <- rADSL }) join_keys(data) <- default_cdisc_join_keys[names(data)] app <- init( data = data, modules = modules( tm_t_crosstable( label = "Cross Table", x = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", 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 ) ), y = data_extract_spec( dataname = "ADSL", select = select_spec( label = "Select variable:", 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 ) ) ) ) ) if (interactive()) { shinyApp(app$ui, app$server) }
teal
module: Variable browserModule provides provides a detailed summary and visualization of variable distributions
for data.frame
objects, with interactive features to customize analysis.
tm_variable_browser( label = "Variable Browser", datasets_selected = character(0), parent_dataname = "ADSL", pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args() )
tm_variable_browser( label = "Variable Browser", datasets_selected = character(0), parent_dataname = "ADSL", pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args() )
label |
( |
datasets_selected |
( |
parent_dataname |
( |
pre_output |
( |
post_output |
( |
ggplot2_args |
( For more details see the vignette: |
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).
Object of class teal_module
to be used in teal
applications.
# 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 <- rADSL ADTTE <- 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) }
# 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 <- rADSL ADTTE <- 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) }