| module_transform_data | R Documentation |
teal_transform_module decorators to reactive teal_dataShiny module pair (srv_transform_teal_data / ui_transform_teal_data) that runs a sequence
of teal_transform_module() decorators against a reactive teal_data object.
Decorators are applied one after another via Reduce, so each one receives the output of the
previous as its data argument.
Failed transformators are tracked and any downstream transformator is automatically disabled
until the failure is resolved.
An optional expr argument allows additional code to be evaluated on the final decorated output.
srv_transform_teal_data(
id,
data,
transformators,
modules = NULL,
is_transform_failed = reactiveValues(),
expr
)
ui_transform_teal_data(id, transformators, class = "well", ...)
id |
( |
data |
( |
transformators |
( |
modules |
|
is_transform_failed |
|
expr |
( |
class |
|
... |
additional arguments passed to |
reactive teal_data
A list of bslib::accordion UI elements, one per transformator, or NULL if
transformators is empty.
assert_decorators()
library(shiny)
library(teal.data)
# A decorator that sets a fixed title on a ggplot2 object named `plot`
static_decorator <- teal_transform_module(
label = "Static decorator",
server = function(id, data) {
moduleServer(id, function(input, output, session) {
reactive({
req(data())
within(data(), {
plot <- plot + ggplot2::ggtitle("Decorated title")
})
})
})
}
)
if (interactive()) {
shinyApp(
ui = fluidPage(
ui_transform_teal_data("decorate", transformators = list(static_decorator)),
plotOutput("plot")
),
server = function(input, output, session) {
data <- reactive(
teal_data(
plot = ggplot2::ggplot(iris, ggplot2::aes(Sepal.Length, Sepal.Width)) +
ggplot2::geom_point()
)
)
decorated <- srv_transform_teal_data(
"decorate",
data = data,
transformators = list(static_decorator)
)
output$plot <- renderPlot(decorated()[["plot"]])
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.