Learn R Programming

teal (version 0.16.0)

make_teal_transform_server: Make teal_transform_module's server

Description

A factory function to simplify creation of a teal_transform_module's server. Specified expr is wrapped in a shiny module function and output can be passed to the server argument in teal_transform_module() call. Such a server function can be linked with ui and values from the inputs can be used in the expression. Object names specified in the expression will be substituted with the value of the respective input (matched by the name) - for example in expression(graph <- graph + ggtitle(title)) object title will be replaced with the value of input$title.

Usage

make_teal_transform_server(expr)

Value

function(id, data) returning shiny module

Arguments

expr

(language) An R call which will be evaluated within teal.data::teal_data environment.

Examples in Shinylive

example-1

Open in Shinylive

Examples

Run this code

trim_iris <- teal_transform_module(
  label = "Simplified interactive transformator for iris",
  datanames = "iris",
  ui = function(id) {
    ns <- NS(id)
    numericInput(ns("n_rows"), "Subset n rows", value = 6, min = 1, max = 150, step = 1)
  },
  server = make_teal_transform_server(expression(iris <- head(iris, n_rows)))
)

app <- init(
  data = teal_data(iris = iris),
  modules = example_module(transformators = trim_iris)
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

Run the code above in your browser using DataLab