The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Teal as a Shiny Module

NEST CoreDev

Introduction

A shiny developer can embed a teal application into their own shiny app by using shiny module components of teal: ui_teal() and srv_teal(). This approach differs from using init() and offers greater flexibility. While init() includes a session info footer automatically, when using teal as a shiny module you can optionally add it manually with ui_session_info() and srv_session_info(). Using teal as a shiny module offers several advantages:

Example

The following example demonstrates embedding teal as a shiny module within a larger shiny application. Users can select dataset names which are passed to the embedded teal component. On the server side, srv_teal() is called with a reactive teal_data object passed from the parent app’s server.

library(teal)

data <- teal_data() |> within({
  iris <- iris
  mtcars <- mtcars
  df <- data.frame(a = 1:10, b = letters[1:10])
})

mods <- modules(
  example_module("mod1"),
  example_module("mod2")
)

ui_app <- fluidPage(
  title = "Your app with teal as a module",
  selectInput("datasets", "Select datasets", choices = c("iris", "mtcars", "df"), selected = "iris", multiple = TRUE),
  ui_teal("teal", mods),
  ui_session_info("session_info")
)

srv_app <- function(input, output, session) {
  data_subset <- reactive(data[input$datasets])
  srv_teal("teal", data = data_subset, modules = mods)
  srv_session_info("session_info")
}

if (interactive()) {
  shinyApp(ui_app, srv_app)
}

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.