Skip to contents

[Stable] This function embeds a shiny module inside a teal application. One teal_module maps to one shiny module.

Usage

module(
  label = "module",
  server = function(id, ...) {
     moduleServer(id, function(input, output, session) {
 
       })
 },
  ui = function(id, ...) {
     tags$p(paste0("This module has no UI (id: ", id, " )"))

    },
  filters = "all",
  server_args = NULL,
  ui_args = NULL
)

# S3 method for teal_module
toString(x, indent = 0, ...)

# S3 method for teal_module
print(x, ...)

Arguments

label

(character(1)) Label shown in the navigation item for the module.

server

(function) shiny module with following arguments:

  • id - teal will set proper shiny namespace for this module (see shiny::moduleServer()).

  • input, output, session - (not recommended) then shiny::callModule() will be used to call a module.

  • data (optional) module will receive a tdata object, a list of reactive (filtered) data specified in the filters argument.

  • datasets (optional) module will receive FilteredData. (See [teal.slice::FilteredData]).

  • reporter (optional) module will receive Reporter. (See teal.reporter::Reporter).

  • ... (optional) server_args elements will be passed to the module named argument or to the ....

ui

(function) Shiny ui module function with following arguments:

  • id - teal will set proper shiny namespace for this module.

  • data (optional) module will receive list of reactive (filtered) data specified in the filters argument.

  • datasets (optional) module will receive FilteredData. (See [teal.slice::FilteredData]).

  • ... (optional) ui_args elements will be passed to the module named argument or to the ....

filters

(character) A vector with datanames that are relevant for the item. The filter panel will automatically update the shown filters to include only filters in the listed datasets. NULL will hide the filter panel, and the keyword 'all' will show the filters of all datasets.

server_args

(named list) with additional arguments passed on to the server function.

ui_args

(named list) with additional arguments passed on to the ui function.

x

teal_module

indent

(integer) indent level; each submodule is indented one level more

...

parameters passed to toString

Value

object of class teal_module.

Examples

library(shiny)

app <- init(
  data = teal_data(dataset("iris", iris)),
  modules = list(
    module(
      label = "Module",
      server = function(id, data) {
        moduleServer(
          id,
          module = function(input, output, session) {
            output$data <- renderDataTable(data[["iris"]]())
          }
        )
      },
      ui = function(id) {
        ns <- NS(id)
        tagList(dataTableOutput(ns("data")))
      }
    )
  )
)
if (FALSE) {
runApp(app)
}