Create a teal_data_module
object for custom transformation of data for pre-processing
before passing the data into the module.
Usage
teal_transform_module(
ui = function(id) NULL,
server = function(id, data) data,
label = "transform module",
datanames = character(0)
)
Arguments
- ui
(
function(id)
)shiny
module UI function; must only takeid
argument- server
-
(
function(id, data)
)shiny
module server function; that takesid
anddata
argument, where theid
is the module id anddata
is the reactiveteal_data
input. The server function must return reactive expression containingteal_data
object.The server function definition should not use
eventReactive
as it may lead to unexpected behavior. Seevignettes("data-transform-as-shiny-module")
for more information. - label
(
character(1)
) Label of the module.- datanames
(
character
) Names of the datasets that are relevant for this module to evaluate. If set tocharacter(0)
then module would receivemodules()
datanames
.
Details
teal_transform_module
creates a teal_data_module
object to transform data in a teal
application. This transformation happens after the data has passed through the filtering activity
in teal. The transformed data is then sent to the server of the teal_module()
.
See vignette vignette("data-transform-as-shiny-module", package = "teal")
for more details.
Examples
my_transformers <- list(
teal_transform_module(
label = "Custom transform for iris",
datanames = "iris",
ui = function(id) {
ns <- NS(id)
tags$div(
numericInput(ns("n_rows"), "Subset n rows", value = 6, min = 1, max = 150, step = 1)
)
},
server = function(id, data) {
moduleServer(id, function(input, output, session) {
reactive({
within(data(),
{
iris <- head(iris, num_rows)
},
num_rows = input$n_rows
)
})
})
}
)
)