Skip to content

Commit fbf27a0

Browse files
m7prgithub-actions[bot]vedhav
authored
Add vignettes on decorators (#843)
Part of insightsengineering/teal#1475 Adds some explanation about decorators functionality of `tmg`, since we will remove/reduce confusing decorators vignette in `teal`. Heavily based on `Customizing Module Output` vignette currently existing in `teal`, with adjustments to show `teal.modules.general` modules. https://github.com/insightsengineering/teal/blob/c70299587cdf8280c75f7320ae09cd3c67c79837/vignettes/customizing-module-output.Rmd --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: vedhav <vedhaviyash4@gmail.com> Co-authored-by: Vedha Viyash <49812166+vedhav@users.noreply.github.com>
1 parent 690b32b commit fbf27a0

26 files changed

+650
-89
lines changed

R/tm_a_pca.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
#' @section Decorating Module:
2121
#'
2222
#' This module generates the following objects, which can be modified in place using decorators:
23-
#' - `elbow_plot` (`ggplot2`)
24-
#' - `circle_plot` (`ggplot2`)
25-
#' - `biplot` (`ggplot2`)
26-
#' - `eigenvector_plot` (`ggplot2`)
23+
#' - `elbow_plot` (`ggplot`)
24+
#' - `circle_plot` (`ggplot`)
25+
#' - `biplot` (`ggplot`)
26+
#' - `eigenvector_plot` (`ggplot`)
2727
#'
2828
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
2929
#' The name of this list corresponds to the name of the output to which the decorator is applied.
@@ -42,6 +42,9 @@
4242
#' ```
4343
#'
4444
#' For additional details and examples of decorators, refer to the vignette
45+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
46+
#'
47+
#' To learn more please refer to the vignette
4548
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
4649
#'
4750
#' @examplesShinylive

R/tm_a_regression.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#' @section Decorating Module:
4747
#'
4848
#' This module generates the following objects, which can be modified in place using decorators:
49-
#' - `plot` (`ggplot2`)
49+
#' - `plot` (`ggplot`)
5050
#'
5151
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
5252
#' The name of this list corresponds to the name of the output to which the decorator is applied.
@@ -62,6 +62,9 @@
6262
#' ```
6363
#'
6464
#' For additional details and examples of decorators, refer to the vignette
65+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
66+
#'
67+
#' To learn more please refer to the vignette
6568
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
6669
#'
6770
#' @examplesShinylive

R/tm_g_association.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#' ```
4444
#'
4545
#' For additional details and examples of decorators, refer to the vignette
46+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
47+
#'
48+
#' To learn more please refer to the vignette
4649
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
4750
#'
4851
#' @examplesShinylive

R/tm_g_bivariate.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#' @section Decorating Module:
5050
#'
5151
#' This module generates the following objects, which can be modified in place using decorators:
52-
#' - `plot` (`ggplot2`)
52+
#' - `plot` (`ggplot`)
5353
#'
5454
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
5555
#' The name of this list corresponds to the name of the output to which the decorator is applied.
@@ -65,6 +65,9 @@
6565
#' ```
6666
#'
6767
#' For additional details and examples of decorators, refer to the vignette
68+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
69+
#'
70+
#' To learn more please refer to the vignette
6871
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
6972
#'
7073
#'

R/tm_g_distribution.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#' @section Decorating Module:
3030
#'
3131
#' This module generates the following objects, which can be modified in place using decorators::
32-
#' - `histogram_plot` (`ggplot2`)
33-
#' - `qq_plot` (`ggplot2`)
32+
#' - `histogram_plot` (`ggplot`)
33+
#' - `qq_plot` (`ggplot`)
3434
#' - `summary_table` (`datatables` created with [DT::datatable()])
3535
#' - `test_table` (`datatables` created with [DT::datatable()])
3636
#'
@@ -51,6 +51,9 @@
5151
#' ```
5252
#'
5353
#' For additional details and examples of decorators, refer to the vignette
54+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
55+
#'
56+
#' To learn more please refer to the vignette
5457
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
5558
#'
5659
#' @examplesShinylive

R/tm_g_response.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#' @section Decorating Module:
4343
#'
4444
#' This module generates the following objects, which can be modified in place using decorators:
45-
#' - `plot` (`ggplot2`)
45+
#' - `plot` (`ggplot`)
4646
#'
4747
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
4848
#' The name of this list corresponds to the name of the output to which the decorator is applied.
@@ -58,6 +58,9 @@
5858
#' ```
5959
#'
6060
#' For additional details and examples of decorators, refer to the vignette
61+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
62+
#'
63+
#' To learn more please refer to the vignette
6164
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
6265
#'
6366
#' @examplesShinylive

R/tm_g_scatterplot.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#' @section Decorating Module:
3434
#'
3535
#' This module generates the following objects, which can be modified in place using decorators:
36-
#' - `plot` (`ggplot2`)
36+
#' - `plot` (`ggplot`)
3737
#'
3838
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
3939
#' The name of this list corresponds to the name of the output to which the decorator is applied.
@@ -49,6 +49,9 @@
4949
#' ```
5050
#'
5151
#' For additional details and examples of decorators, refer to the vignette
52+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
53+
#'
54+
#' To learn more please refer to the vignette
5255
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
5356
#'
5457
#'

R/tm_g_scatterplotmatrix.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#' ```
3838
#'
3939
#' For additional details and examples of decorators, refer to the vignette
40+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
41+
#'
42+
#' To learn more please refer to the vignette
4043
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
4144
#'
4245
#' @examplesShinylive

R/tm_missing_data.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#' This module generates the following objects, which can be modified in place using decorators:
2323
#' - `summary_plot` (`grob` created with [ggplot2::ggplotGrob()])
2424
#' - `combination_plot` (`grob` created with [ggplot2::ggplotGrob()])
25-
#' - `by_subject_plot` (`ggplot2`)
26-
#' - `table` (`datatable` created with [DT::datatable()])
25+
#' - `by_subject_plot` (`ggplot`)
26+
#' - `table` (`datatables` created with [DT::datatable()])
2727
#'
2828
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
2929
#' The name of this list corresponds to the name of the output to which the decorator is applied.
@@ -42,6 +42,9 @@
4242
#' ```
4343
#'
4444
#' For additional details and examples of decorators, refer to the vignette
45+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
46+
#'
47+
#' To learn more please refer to the vignette
4548
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
4649
#'
4750
#' @examplesShinylive

R/tm_outliers.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#' @section Decorating Module:
1919
#'
2020
#' This module generates the following objects, which can be modified in place using decorators:
21-
#' - `box_plot` (`ggplot2`)
22-
#' - `density_plot` (`ggplot2`)
23-
#' - `cumulative_plot` (`ggplot2`)
24-
#' - `table` (`datatable` created with [DT::datatable()])
21+
#' - `box_plot` (`ggplot`)
22+
#' - `density_plot` (`ggplot`)
23+
#' - `cumulative_plot` (`ggplot`)
24+
#' - `table` (`datatables` created with [DT::datatable()])
2525
#'
2626
#' A Decorator is applied to the specific output using a named list of `teal_transform_module` objects.
2727
#' The name of this list corresponds to the name of the output to which the decorator is applied.
@@ -40,6 +40,9 @@
4040
#' ```
4141
#'
4242
#' For additional details and examples of decorators, refer to the vignette
43+
#' `vignette("decorate-module-output", package = "teal.modules.general")`.
44+
#'
45+
#' To learn more please refer to the vignette
4346
#' `vignette("transform-module-output", package = "teal")` or the [`teal::teal_transform_module()`] documentation.
4447
#'
4548
#' @examplesShinylive
@@ -533,12 +536,12 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
533536
# this is utils function that converts a %>% NULL %>% b into a %>% b
534537
remove_pipe_null <- function(x) {
535538
if (length(x) == 1) {
536-
return(x)
537-
}
538-
if (identical(x[[1]], as.name("%>%")) && is.null(x[[3]])) {
539-
return(remove_pipe_null(x[[2]]))
539+
x
540+
} else if (identical(x[[1]], as.name("%>%")) && is.null(x[[3]])) {
541+
remove_pipe_null(x[[2]])
542+
} else {
543+
as.call(c(x[[1]], lapply(x[-1], remove_pipe_null)))
540544
}
541-
return(as.call(c(x[[1]], lapply(x[-1], remove_pipe_null))))
542545
}
543546

544547
qenv <- teal.code::eval_code(

0 commit comments

Comments
 (0)