diff --git a/NEWS.md b/NEWS.md index 8b1d56d23b..137777c6b1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,7 @@ ### New features * Possible to call `ui_teal` and `srv_teal` directly in any application by delivering `data` argument as a `reactive` returning `teal_data` object. #669 -* Introduced `teal_transform_module` to provide a way to interactively modify data delivered to `teal_module`'s `server` and to modify module outputs. #1228 #1384 +* Introduced `teal_transform_module` to provide a way to interactively modify data delivered to `teal_module`'s `server` and to decorate module outputs. #1228 #1384 * Introduced a new argument `once = FALSE` in `teal_data_module` to possibly reload data during a run time. * Possibility to download lockfile to restore app session for reproducibility. #479 * Introduced a function `set_datanames()` to change a `datanames` of the `teal_module`. diff --git a/vignettes/decorate-multiple-modules-outputs.Rmd b/vignettes/decorate-multiple-modules-outputs.Rmd index c619f5a458..f13299fc0e 100644 --- a/vignettes/decorate-multiple-modules-outputs.Rmd +++ b/vignettes/decorate-multiple-modules-outputs.Rmd @@ -56,6 +56,7 @@ tm_decorated_plot <- function( }) observeEvent(input$dataname, { + req(input$dataname) updateSelectInput(inputId = "x", choices = colnames(data()[[input$dataname]])) updateSelectInput(inputId = "y", label = "select y", choices = colnames(data()[[input$dataname]])) }) @@ -72,36 +73,34 @@ tm_decorated_plot <- function( q1_1 <- reactive({ req(input$dataname, input$x, input$y) - data() |> - within( - { - plot_1 <- ggplot2::ggplot(dataname, ggplot2::aes(x = x, y = y)) + - ggplot2::geom_point() + - ggtitle("plot 1") - }, - dataname = as.name(input$dataname), - x = as.name(input$x), - y = as.name(input$y) - ) + within(data(), + { + plot_1 <- ggplot2::ggplot(dataname, ggplot2::aes(x = x, y = y)) + + ggplot2::geom_point() + + ggtitle("plot 1") + }, + dataname = as.name(input$dataname), + x = as.name(input$x), + y = as.name(input$y) + ) }) q2_1 <- reactive({ req(input$dataname, input$x, input$y) - data() |> - within( - { - plot_2 <- ggplot2::ggplot(dataname, ggplot2::aes(x = x, y = y)) + - ggplot2::geom_point() + - ggtitle("plot 2") - }, - dataname = as.name(input$dataname), - x = as.name(input$x), - y = as.name(input$y) - ) + within(data(), + { + plot_2 <- ggplot2::ggplot(dataname, ggplot2::aes(x = x, y = y)) + + ggplot2::geom_point() + + ggtitle("plot 2") + }, + dataname = as.name(input$dataname), + x = as.name(input$x), + y = as.name(input$y) + ) }) - q1_2 <- srv_teal_data("decorate_1", data = q1_1, data_module = decorator_objs[[1]], modules = module()) - q2_2 <- srv_teal_data("decorate_2", data = q2_1, data_module = decorator_objs[[2]], modules = module()) + q1_2 <- srv_transform_data("decorate_1", data = q1_1, data_module = decorator_objs[[1]], modules = module()) + q2_2 <- srv_transform_data("decorate_2", data = q2_1, data_module = decorator_objs[[2]], modules = module()) plot_r <- reactive({ @@ -144,7 +143,7 @@ interactive_decorator_1 <- teal_transform_module( moduleServer(id, function(input, output, session) { reactive({ req(data()) - data() |> within( + within(data(), { plot_1 <- plot_1 + xlab(x_axis_title) @@ -167,7 +166,7 @@ interactive_decorator_2 <- teal_transform_module( moduleServer(id, function(input, output, session) { reactive({ req(data()) - data() |> within( + within(data(), { plot_2 <- plot_2 + xlab(x_axis_title)