diff --git a/R/tm_a_pca.R b/R/tm_a_pca.R index 4f7e96f76..7227856f1 100644 --- a/R/tm_a_pca.R +++ b/R/tm_a_pca.R @@ -20,10 +20,10 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `elbow_plot` (`ggplot2`) -#' - `circle_plot` (`ggplot2`) -#' - `biplot` (`ggplot2`) -#' - `eigenvector_plot` (`ggplot2`) +#' - `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. @@ -42,6 +42,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive diff --git a/R/tm_a_regression.R b/R/tm_a_regression.R index 54c533ad3..5ec46337a 100644 --- a/R/tm_a_regression.R +++ b/R/tm_a_regression.R @@ -46,7 +46,7 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `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. @@ -62,6 +62,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive diff --git a/R/tm_g_association.R b/R/tm_g_association.R index 3755e98f3..637364fce 100644 --- a/R/tm_g_association.R +++ b/R/tm_g_association.R @@ -43,6 +43,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive diff --git a/R/tm_g_bivariate.R b/R/tm_g_bivariate.R index e745f3aff..46b769f9e 100644 --- a/R/tm_g_bivariate.R +++ b/R/tm_g_bivariate.R @@ -49,7 +49,7 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `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. @@ -65,6 +65,9 @@ #' ``` #' #' 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. #' #' diff --git a/R/tm_g_distribution.R b/R/tm_g_distribution.R index 5abd221b7..12ea14ea1 100644 --- a/R/tm_g_distribution.R +++ b/R/tm_g_distribution.R @@ -29,8 +29,8 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators:: -#' - `histogram_plot` (`ggplot2`) -#' - `qq_plot` (`ggplot2`) +#' - `histogram_plot` (`ggplot`) +#' - `qq_plot` (`ggplot`) #' - `summary_table` (`datatables` created with [DT::datatable()]) #' - `test_table` (`datatables` created with [DT::datatable()]) #' @@ -51,6 +51,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive diff --git a/R/tm_g_response.R b/R/tm_g_response.R index 5a9073dbd..c833d1bd3 100644 --- a/R/tm_g_response.R +++ b/R/tm_g_response.R @@ -42,7 +42,7 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `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. @@ -58,6 +58,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive diff --git a/R/tm_g_scatterplot.R b/R/tm_g_scatterplot.R index d5c594f79..e9c8ce3c6 100644 --- a/R/tm_g_scatterplot.R +++ b/R/tm_g_scatterplot.R @@ -33,7 +33,7 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `plot` (`ggplot2`) +#' - `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. @@ -49,6 +49,9 @@ #' ``` #' #' 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. #' #' diff --git a/R/tm_g_scatterplotmatrix.R b/R/tm_g_scatterplotmatrix.R index 13b801c26..e4eddb7cd 100644 --- a/R/tm_g_scatterplotmatrix.R +++ b/R/tm_g_scatterplotmatrix.R @@ -37,6 +37,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive diff --git a/R/tm_missing_data.R b/R/tm_missing_data.R index 8b6268947..ff89c47c8 100644 --- a/R/tm_missing_data.R +++ b/R/tm_missing_data.R @@ -22,8 +22,8 @@ #' This module generates the following objects, which can be modified in place using decorators: #' - `summary_plot` (`grob` created with [ggplot2::ggplotGrob()]) #' - `combination_plot` (`grob` created with [ggplot2::ggplotGrob()]) -#' - `by_subject_plot` (`ggplot2`) -#' - `table` (`datatable` created with [DT::datatable()]) +#' - `by_subject_plot` (`ggplot`) +#' - `table` (`datatables` created with [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. @@ -42,6 +42,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive diff --git a/R/tm_outliers.R b/R/tm_outliers.R index 96526ffb0..e9ee4036d 100644 --- a/R/tm_outliers.R +++ b/R/tm_outliers.R @@ -18,10 +18,10 @@ #' @section Decorating Module: #' #' This module generates the following objects, which can be modified in place using decorators: -#' - `box_plot` (`ggplot2`) -#' - `density_plot` (`ggplot2`) -#' - `cumulative_plot` (`ggplot2`) -#' - `table` (`datatable` created with [DT::datatable()]) +#' - `box_plot` (`ggplot`) +#' - `density_plot` (`ggplot`) +#' - `cumulative_plot` (`ggplot`) +#' - `table` (`datatables` created with [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. @@ -40,6 +40,9 @@ #' ``` #' #' 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. #' #' @examplesShinylive @@ -533,12 +536,12 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var, # this is utils function that converts a %>% NULL %>% b into a %>% b remove_pipe_null <- function(x) { if (length(x) == 1) { - return(x) - } - if (identical(x[[1]], as.name("%>%")) && is.null(x[[3]])) { - return(remove_pipe_null(x[[2]])) + x + } else if (identical(x[[1]], as.name("%>%")) && is.null(x[[3]])) { + remove_pipe_null(x[[2]]) + } else { + as.call(c(x[[1]], lapply(x[-1], remove_pipe_null))) } - return(as.call(c(x[[1]], lapply(x[-1], remove_pipe_null)))) } qenv <- teal.code::eval_code( diff --git a/R/tm_t_crosstable.R b/R/tm_t_crosstable.R index 0b410e73e..c2ae8ae8a 100644 --- a/R/tm_t_crosstable.R +++ b/R/tm_t_crosstable.R @@ -43,6 +43,9 @@ #' ) #' ``` #' 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. #' #' @examplesShinylive diff --git a/R/utils.R b/R/utils.R index 44da1c3eb..5eb3609fd 100644 --- a/R/utils.R +++ b/R/utils.R @@ -34,11 +34,9 @@ #' - When the length of `size` is three: the plot points size are dynamically adjusted based on #' vector of `value`, `min`, and `max`. #' @param decorators `r lifecycle::badge("experimental")` -#' (`list` of `teal_transform_module`, named `list` of `teal_transform_module`) optional, +#' (named `list` of lists of `teal_transform_module`) optional, #' decorator for tables or plots included in the module output reported. -#' When a named list of `teal_transform_module`, the decorators are applied to the respective output objects. -#' -#' Otherwise, the decorators are applied to all objects, which is equivalent as using the name `default`. +#' The decorators are applied to the respective output objects. #' #' See section "Decorating Module" below for more details. #' diff --git a/inst/WORDLIST b/inst/WORDLIST index d00a0162f..6f9477d61 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,3 +1,4 @@ +ElementaryTable Forkers Hoffmann Prebuilt @@ -5,9 +6,12 @@ Shinylive TLG UI customizable +datatables facetting funder +ggplot pre +qq repo reproducibility sortable diff --git a/man/shared_params.Rd b/man/shared_params.Rd index 18738add1..5e27ea0dc 100644 --- a/man/shared_params.Rd +++ b/man/shared_params.Rd @@ -49,11 +49,9 @@ vector of \code{value}, \code{min}, and \code{max}. }} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } diff --git a/man/tm_a_pca.Rd b/man/tm_a_pca.Rd index 65e890c3a..2fdfdf650 100644 --- a/man/tm_a_pca.Rd +++ b/man/tm_a_pca.Rd @@ -77,11 +77,9 @@ adding context or further instructions. Elements like \code{shiny::helpText()} a To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -99,10 +97,10 @@ font size, through UI inputs. This module generates the following objects, which can be modified in place using decorators: \itemize{ -\item \code{elbow_plot} (\code{ggplot2}) -\item \code{circle_plot} (\code{ggplot2}) -\item \code{biplot} (\code{ggplot2}) -\item \code{eigenvector_plot} (\code{ggplot2}) +\item \code{elbow_plot} (\code{ggplot}) +\item \code{circle_plot} (\code{ggplot}) +\item \code{biplot} (\code{ggplot}) +\item \code{eigenvector_plot} (\code{ggplot}) } A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. @@ -121,6 +119,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_a_regression.Rd b/man/tm_a_regression.Rd index 71dc791b9..37a215e71 100644 --- a/man/tm_a_regression.Rd +++ b/man/tm_a_regression.Rd @@ -101,11 +101,9 @@ argument in \code{teal.widgets::optionalSliderInputValMinMax}. To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -127,7 +125,7 @@ For more examples, please see the vignette "Using regression plots" via This module generates the following objects, which can be modified in place using decorators: \itemize{ -\item \code{plot} (\code{ggplot2}) +\item \code{plot} (\code{ggplot}) } A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. @@ -143,6 +141,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_g_association.Rd b/man/tm_g_association.Rd index df1936df7..9e651dc70 100644 --- a/man/tm_g_association.Rd +++ b/man/tm_g_association.Rd @@ -62,11 +62,9 @@ For more details see the vignette: \code{vignette("custom-ggplot2-arguments", pa To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -103,6 +101,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_g_bivariate.Rd b/man/tm_g_bivariate.Rd index 6572fd926..09fd2e2d2 100644 --- a/man/tm_g_bivariate.Rd +++ b/man/tm_g_bivariate.Rd @@ -107,11 +107,9 @@ adding context or further instructions. Elements like \code{shiny::helpText()} a To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -134,7 +132,7 @@ For more examples, please see the vignette "Using bivariate plot" via This module generates the following objects, which can be modified in place using decorators: \itemize{ -\item \code{plot} (\code{ggplot2}) +\item \code{plot} (\code{ggplot}) } A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. @@ -150,6 +148,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_g_distribution.Rd b/man/tm_g_distribution.Rd index 85d0f49dc..a064a26fe 100644 --- a/man/tm_g_distribution.Rd +++ b/man/tm_g_distribution.Rd @@ -69,11 +69,9 @@ into context. For example the \code{\link[shiny:helpText]{shiny::helpText()}} el To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -90,8 +88,8 @@ visually and statistically analyze the variable's distribution. This module generates the following objects, which can be modified in place using decorators:: \itemize{ -\item \code{histogram_plot} (\code{ggplot2}) -\item \code{qq_plot} (\code{ggplot2}) +\item \code{histogram_plot} (\code{ggplot}) +\item \code{qq_plot} (\code{ggplot}) \item \code{summary_table} (\code{datatables} created with \code{\link[DT:datatable]{DT::datatable()}}) \item \code{test_table} (\code{datatables} created with \code{\link[DT:datatable]{DT::datatable()}}) } @@ -112,6 +110,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_g_response.Rd b/man/tm_g_response.Rd index 48ea07692..2a617112a 100644 --- a/man/tm_g_response.Rd +++ b/man/tm_g_response.Rd @@ -87,11 +87,9 @@ adding context or further instructions. Elements like \code{shiny::helpText()} a To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -115,7 +113,7 @@ For more examples, please see the vignette "Using response plot" via This module generates the following objects, which can be modified in place using decorators: \itemize{ -\item \code{plot} (\code{ggplot2}) +\item \code{plot} (\code{ggplot}) } A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. @@ -131,6 +129,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_g_scatterplot.Rd b/man/tm_g_scatterplot.Rd index 51c0bfd06..556c87b34 100644 --- a/man/tm_g_scatterplot.Rd +++ b/man/tm_g_scatterplot.Rd @@ -100,11 +100,9 @@ For more details see the vignette: \code{vignette("custom-ggplot2-arguments", pa To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -126,7 +124,7 @@ For more examples, please see the vignette "Using scatterplot" via This module generates the following objects, which can be modified in place using decorators: \itemize{ -\item \code{plot} (\code{ggplot2}) +\item \code{plot} (\code{ggplot}) } A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. @@ -142,6 +140,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_g_scatterplotmatrix.Rd b/man/tm_g_scatterplotmatrix.Rd index 0825f2e09..f90d7cf52 100644 --- a/man/tm_g_scatterplotmatrix.Rd +++ b/man/tm_g_scatterplotmatrix.Rd @@ -41,11 +41,9 @@ adding context or further instructions. Elements like \code{shiny::helpText()} a To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -82,6 +80,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_missing_data.Rd b/man/tm_missing_data.Rd index e950dc8e4..6d2f03824 100644 --- a/man/tm_missing_data.Rd +++ b/man/tm_missing_data.Rd @@ -62,11 +62,9 @@ adding context or further instructions. Elements like \code{shiny::helpText()} a To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -86,8 +84,8 @@ This module generates the following objects, which can be modified in place usin \itemize{ \item \code{summary_plot} (\code{grob} created with \code{\link[ggplot2:ggplotGrob]{ggplot2::ggplotGrob()}}) \item \code{combination_plot} (\code{grob} created with \code{\link[ggplot2:ggplotGrob]{ggplot2::ggplotGrob()}}) -\item \code{by_subject_plot} (\code{ggplot2}) -\item \code{table} (\code{datatable} created with \code{\link[DT:datatable]{DT::datatable()}}) +\item \code{by_subject_plot} (\code{ggplot}) +\item \code{table} (\code{datatables} created with \code{\link[DT:datatable]{DT::datatable()}}) } A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. @@ -106,6 +104,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_outliers.Rd b/man/tm_outliers.Rd index 269624e94..f8c15278d 100644 --- a/man/tm_outliers.Rd +++ b/man/tm_outliers.Rd @@ -53,11 +53,9 @@ adding context or further instructions. Elements like \code{shiny::helpText()} a To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -74,10 +72,10 @@ box plots, density plots, and cumulative distribution plots to help interpret th This module generates the following objects, which can be modified in place using decorators: \itemize{ -\item \code{box_plot} (\code{ggplot2}) -\item \code{density_plot} (\code{ggplot2}) -\item \code{cumulative_plot} (\code{ggplot2}) -\item \code{table} (\code{datatable} created with \code{\link[DT:datatable]{DT::datatable()}}) +\item \code{box_plot} (\code{ggplot}) +\item \code{density_plot} (\code{ggplot}) +\item \code{cumulative_plot} (\code{ggplot}) +\item \code{table} (\code{datatables} created with \code{\link[DT:datatable]{DT::datatable()}}) } A Decorator is applied to the specific output using a named list of \code{teal_transform_module} objects. @@ -96,6 +94,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/man/tm_t_crosstable.Rd b/man/tm_t_crosstable.Rd index e2f710701..c761018da 100644 --- a/man/tm_t_crosstable.Rd +++ b/man/tm_t_crosstable.Rd @@ -56,11 +56,9 @@ For more details see the vignette: \code{vignette("custom-basic-table-arguments" To learn more check \code{vignette("transform-input-data", package = "teal")}.} \item{decorators}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -(\code{list} of \code{teal_transform_module}, named \code{list} of \code{teal_transform_module}) optional, +(named \code{list} of lists of \code{teal_transform_module}) optional, decorator for tables or plots included in the module output reported. -When a named list of \code{teal_transform_module}, the decorators are applied to the respective output objects. - -Otherwise, the decorators are applied to all objects, which is equivalent as using the name \code{default}. +The decorators are applied to the respective output objects. See section "Decorating Module" below for more details.} } @@ -96,6 +94,9 @@ See code snippet below: }\if{html}{\out{}} For additional details and examples of decorators, refer to the vignette +\code{vignette("decorate-module-output", package = "teal.modules.general")}. + +To learn more please refer to the vignette \code{vignette("transform-module-output", package = "teal")} or the \code{\link[teal:teal_transform_module]{teal::teal_transform_module()}} documentation. } diff --git a/vignettes/decorate-module-output.Rmd b/vignettes/decorate-module-output.Rmd new file mode 100644 index 000000000..321224e3e --- /dev/null +++ b/vignettes/decorate-module-output.Rmd @@ -0,0 +1,517 @@ +--- +title: "Decorate Module Output" +author: "NEST CoreDev" +output: + rmarkdown::html_vignette: + toc: true +vignette: > + %\VignetteIndexEntry{Decorate Module Output} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r setup, include=FALSE} +library(teal.modules.general) +``` + + +## Introduction + +The outputs produced by `teal` modules, like graphs or tables, are created by the module developer and look a certain way. +It is hard to design an output that will satisfy every possible user, so the form of the output should be considered a default value that can be customized. +Here we describe the concept of _decoration_, enabling the app developer to tailor outputs to their specific requirements without rewriting the original module code. + +The decoration process is build upon transformation procedures, introduced in `teal`. +While `transformators` are meant to edit module's input, decorators are meant to adjust the module's output. +To distinguish the difference, modules in `teal.modules.general` have 2 separate parameters: +`transformators` and `decorators`. + +To get a complete understanding refer the following vignettes: + +- Transforming the input data in +[this vignette](https://insightsengineering.github.io/teal/latest-tag/articles/transform-input-data.html). +- Transforming module output in [this vignette](https://insightsengineering.github.io/teal/latest-tag/articles/transform-module-output.html). + +## Outputs that can be decorated + +It is important to note which output objects from a given module can be decorated. +The module function documentation's _Decorating Module_ section has this information. + +You can also refer the table shown below to know which module outputs can be decorated. + +| Module | Output (Class) | +|------------------------|----------------------------------------------------| +| `tm_a_pca` | elbow_plot (ggplot), circle_plot (ggplot), biplot (ggplot), eigenvector_plot (ggplot) | +| `tm_a_regression` | plot (ggplot) | +| `tm_g_association` | plot (grob) | +| `tm_g_bivariate` | plot (ggplot) | +| `tm_g_distribution` | histogram_plot (ggplot), qq_plot (ggplot), summary_table (datatables), test_table (datatables) | +| `tm_g_response` | plot (ggplot) | +| `tm_g_scatterplot` | plot (ggplot) | +| `tm_g_scatterplotmatrix` | plot (trellis) | +| `tm_missing_data` | summary_plot (grob), combination_plot (grob), by_subject_plot (ggplot), table (datatables) | +| `tm_outliers` | box_plot (ggplot), density_plot (ggplot), cumulative_plot (ggplot), table (datatables) | +| `tm_t_crosstable` | table (ElementaryTable) | + +Also, note that there are five different types of objects that can be decorated: + +1. `ElementaryTable` +2. `ggplot` +3. `grob` +4. `datatables` +5. `trellis` + +*Tip:* A general tip before trying to decorate the output from the module is to +copy the reproducible code and running them in a separate R session to +quickly iterate the decoration you want. + +## Decorating `ElementaryTable` + +Here's an example to showcase how you can edit an output of class `ElementaryTable`. +`rtables` modifiers like `rtables::insert_rrow` can be applied to modify this object. + +```{r decorate_ElementaryTable, message=FALSE} +library(teal.modules.general) + +data <- teal_data(join_keys = default_cdisc_join_keys[c("ADSL", "ADRS")]) +data <- within(data, { + require(nestcolor) + ADSL <- rADSL +}) + +insert_rrow_decorator <- function(default_caption = "I am a good new row") { + teal_transform_module( + label = "New row", + ui = function(id) { + shiny::textInput(shiny::NS(id, "new_row"), "New row", value = default_caption) + }, + server = function(id, data) { + moduleServer(id, function(input, output, session) { + reactive({ + data() |> + within( + { + table <- rtables::insert_rrow(table, rtables::rrow(new_row)) + }, + new_row = input$new_row + ) + }) + }) + } + ) +} + +app <- init( + data = data, + modules = modules( + tm_t_crosstable( + label = "Cross Table", + x = data_extract_spec( + dataname = "ADSL", + select = select_spec( + choices = variable_choices(data[["ADSL"]], subset = function(data) { + idx <- !vapply(data, inherits, logical(1), c("Date", "POSIXct", "POSIXlt")) + names(data)[idx] + }), + selected = "COUNTRY", + multiple = TRUE, + ordered = TRUE + ) + ), + y = data_extract_spec( + dataname = "ADSL", + select = select_spec( + choices = variable_choices(data[["ADSL"]], subset = function(data) { + idx <- vapply(data, is.factor, logical(1)) + names(data)[idx] + }), + selected = "SEX" + ) + ), + decorators = list( + table = insert_rrow_decorator() + ) + ) + ) +) + +if (interactive()) { + shinyApp(app$ui, app$server) +} +``` + +```{r shinylive_iframe_1, echo = FALSE, out.width = '150%', out.extra = 'style = "position: relative; z-index:1"', eval = requireNamespace("roxy.shinylive", quietly = TRUE) && knitr::is_html_output() && identical(Sys.getenv("IN_PKGDOWN"), "true")} +code <- paste0(c( + "interactive <- function() TRUE", + knitr::knit_code$get("setup"), + knitr::knit_code$get("decorate_ElementaryTable") +), collapse = "\n") + +url <- roxy.shinylive::create_shinylive_url(code) +knitr::include_url(url, height = "800px") +``` + +## Decorating `ggplot` + +Here's an example to showcase how you can edit an output of class `ggplot`. +You can extend them using `ggplot2` functions. + +```{r decorate_ggplot, message=FALSE} +library(teal.modules.general) + +data <- teal_data(join_keys = default_cdisc_join_keys[c("ADSL", "ADRS")]) +data <- within(data, { + require(nestcolor) + ADSL <- rADSL +}) + +ggplot_caption_decorator <- function(default_caption = "I am a good decorator") { + teal_transform_module( + label = "Caption", + ui = function(id) { + shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption) + }, + server = function(id, data) { + moduleServer(id, function(input, output, session) { + reactive({ + data() |> + within( + { + plot <- plot + ggplot2::labs(caption = footnote) + }, + footnote = input$footnote + ) + }) + }) + } + ) +} + +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 + ) + ), + decorators = list( + plot = ggplot_caption_decorator("I am a Regression") + ) + ) + ) +) + +if (interactive()) { + shinyApp(app$ui, app$server) +} +``` + +```{r shinylive_iframe_2, echo = FALSE, out.width = '150%', out.extra = 'style = "position: relative; z-index:1"', eval = requireNamespace("roxy.shinylive", quietly = TRUE) && knitr::is_html_output() && identical(Sys.getenv("IN_PKGDOWN"), "true")} +code <- paste0(c( + "interactive <- function() TRUE", + knitr::knit_code$get("setup"), + knitr::knit_code$get("decorate_ggplot") +), collapse = "\n") + +url <- roxy.shinylive::create_shinylive_url(code) +knitr::include_url(url, height = "800px") +``` + +## Decorating `grob` + +Here's an example to showcase how you can edit an output of class `grob`. +You can extend them using `grid` and `gridExtra` functions. + +```{r decorate_grob, message=FALSE} +library(teal.modules.general) + +data <- teal_data(join_keys = default_cdisc_join_keys[c("ADSL", "ADRS")]) +data <- within(data, { + ADSL <- rADSL +}) + +grob_caption_decorator <- function(default_caption = "I am a good decorator") { + teal_transform_module( + label = "Caption", + ui = function(id) { + shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption) + }, + server = function(id, data) { + moduleServer(id, function(input, output, session) { + reactive({ + data() |> + within( + { + footnote_grob <- grid::textGrob( + footnote, + x = 0, hjust = 0, + gp = grid::gpar(fontsize = 10, fontface = "italic", col = "gray50") + ) + plot <- gridExtra::arrangeGrob( + plot, + footnote_grob, + ncol = 1, + heights = grid::unit.c( + grid::unit(1, "npc") - grid::unit(1, "lines"), grid::unit(1, "lines") + ) + ) + }, + footnote = input$footnote + ) + }) + }) + } + ) +} + +app <- init( + data = data, + modules = modules( + tm_g_association( + ref = data_extract_spec( + dataname = "ADSL", + select = select_spec( + choices = variable_choices( + data[["ADSL"]], + c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2") + ), + selected = "RACE" + ) + ), + vars = data_extract_spec( + dataname = "ADSL", + select = select_spec( + choices = variable_choices( + data[["ADSL"]], + c("SEX", "RACE", "COUNTRY", "ARM", "STRATA1", "STRATA2", "ITTFL", "BMRKR2") + ), + selected = "BMRKR2", + multiple = TRUE + ) + ), + decorators = list( + plot = grob_caption_decorator("I am a Association") + ) + ) + ) +) + +if (interactive()) { + shinyApp(app$ui, app$server) +} +``` + +```{r shinylive_iframe_3, echo = FALSE, out.width = '150%', out.extra = 'style = "position: relative; z-index:1"', eval = requireNamespace("roxy.shinylive", quietly = TRUE) && knitr::is_html_output() && identical(Sys.getenv("IN_PKGDOWN"), "true")} +code <- paste0(c( + "interactive <- function() TRUE", + knitr::knit_code$get("setup"), + knitr::knit_code$get("decorate_grob") +), collapse = "\n") + +url <- roxy.shinylive::create_shinylive_url(code) +knitr::include_url(url, height = "800px") +``` + +## Decorating `datatables` + +Here's an example to showcase how you can edit an output of class `datatables`. +Please refer the [helper functions](https://rstudio.github.io/DT/functions.html) of the `DT` package to learn more about extending the `datatables` objects. +```{r decorate_datatables} +library(teal.modules.general) + +data <- teal_data(join_keys = default_cdisc_join_keys[c("ADSL", "ADRS")]) +data <- within(data, { + require(nestcolor) + ADSL <- rADSL +}) +fact_vars_adsl <- names(Filter(isTRUE, sapply(data[["ADSL"]], is.factor))) +vars <- choices_selected(variable_choices(data[["ADSL"]], fact_vars_adsl)) + +dt_table_decorator <- function(color1 = "pink", color2 = "lightblue") { + teal_transform_module( + label = "Table color", + ui = function(id) { + selectInput( + NS(id, "color"), + "Table Color", + choices = c("white", color1, color2), + selected = "Default" + ) + }, + server = function(id, data) { + moduleServer(id, function(input, output, session) { + reactive({ + data() |> within( + { + summary_table <- DT::formatStyle( + summary_table, + columns = attr(summary_table$x, "colnames")[-1], + target = "row", + backgroundColor = color + ) + }, + color = input$color + ) + }) + }) + } + ) +} + +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 = vars, + multiple = TRUE + ) + ), + group_var = data_extract_spec( + dataname = "ADSL", + filter = filter_spec( + vars = vars, + multiple = TRUE + ) + ), + decorators = list( + summary_table = dt_table_decorator() + ) + ) + ) +) + +if (interactive()) { + shinyApp(app$ui, app$server) +} +``` + +```{r shinylive_iframe_4, echo = FALSE, out.width = '150%', out.extra = 'style = "position: relative; z-index:1"', eval = requireNamespace("roxy.shinylive", quietly = TRUE) && knitr::is_html_output() && identical(Sys.getenv("IN_PKGDOWN"), "true")} +code <- paste0(c( + "interactive <- function() TRUE", + knitr::knit_code$get("setup"), + knitr::knit_code$get("decorate_datatables") +), collapse = "\n") + +url <- roxy.shinylive::create_shinylive_url(code) +knitr::include_url(url, height = "800px") +``` + +## Decorating `trellis` + +Here's an example to showcase how you can edit an output of class `trellis`. +`rtables` modifiers like `rtables::insert_rrow` can be applied to modify this object. + +```{r decorate_trellis, message=FALSE} +library(teal.modules.general) + +data <- teal_data(join_keys = default_cdisc_join_keys[c("ADSL", "ADRS")]) +data <- within(data, { + require(nestcolor) + ADSL <- rADSL + ADRS <- rADRS +}) + +trellis_subtitle_decorator <- function(default_caption = "I am a good decorator") { + teal_transform_module( + label = "Caption", + ui = function(id) shiny::textInput(shiny::NS(id, "footnote"), "Footnote", value = default_caption), + server = function(id, data) { + moduleServer(id, function(input, output, session) { + reactive({ + data() |> + within( + { + plot <- update(plot, sub = footnote) + }, + footnote = input$footnote + ) + }) + }) + } + ) +} + +app <- init( + data = data, + modules = modules( + tm_g_scatterplotmatrix( + label = "Scatterplot matrix", + variables = list( + data_extract_spec( + dataname = "ADSL", + select = select_spec( + choices = variable_choices(data[["ADSL"]]), + selected = c("AGE", "RACE", "SEX"), + multiple = TRUE, + ordered = TRUE + ) + ), + 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( + choices = variable_choices(data[["ADRS"]]), + selected = c("AGE", "AVAL", "ADY"), + multiple = TRUE, + ordered = TRUE + ) + ) + ), + decorators = list( + plot = trellis_subtitle_decorator("I am a Scatterplot matrix") + ) + ) + ) +) + +if (interactive()) { + shinyApp(app$ui, app$server) +} +``` + +```{r shinylive_iframe_5, echo = FALSE, out.width = '150%', out.extra = 'style = "position: relative; z-index:1"', eval = requireNamespace("roxy.shinylive", quietly = TRUE) && knitr::is_html_output() && identical(Sys.getenv("IN_PKGDOWN"), "true")} +code <- paste0(c( + "interactive <- function() TRUE", + knitr::knit_code$get("setup"), + knitr::knit_code$get("decorate_trellis") +), collapse = "\n") + +url <- roxy.shinylive::create_shinylive_url(code) +knitr::include_url(url, height = "800px") +```