End-users: This is the most important function for you to start a
teal
app that is composed of teal
modules.
Usage
init(
data,
modules,
filter = teal_slices(),
title = build_app_title(),
header = tags$p(),
footer = tags$p(),
id = character(0),
landing_popup = NULL
)
Arguments
- data
(
teal_data
orteal_data_module
) For constructing the data object, refer toteal_data()
andteal_data_module()
. Ifdatanames
are not set for theteal_data
object, defaults from theteal_data
environment will be used.- modules
(
list
orteal_modules
orteal_module
) Nested list ofteal_modules
orteal_module
objects or a singleteal_modules
orteal_module
object. These are the specific output modules which will be displayed in theteal
application. Seemodules()
andmodule()
for more details.- filter
(
teal_slices
) Optionally, specifies the initial filter usingteal_slices()
.- title
(
shiny.tag
orcharacter(1)
) Optionally, the browser window title. Defaults to a title "teal app" with the icon of NEST. Can be created using thebuild_app_title()
or by passing a validshiny.tag
which is a head tag with title and link tag.- header
(
shiny.tag
orcharacter(1)
) Optionally, the header of the app.(
shiny.tag
orcharacter(1)
) Optionally, the footer of the app.- id
(
character
) Optionally, a string specifying theshiny
module id in cases it is used as ashiny
module rather than a standaloneshiny
app. This is a legacy feature.- landing_popup
(
teal_module_landing
) Optionally, alanding_popup_module
to show up as soon as the teal app is initialized.
Examples
app <- init(
data = within(
teal_data(),
{
new_iris <- transform(iris, id = seq_len(nrow(iris)))
new_mtcars <- transform(mtcars, id = seq_len(nrow(mtcars)))
}
),
modules = modules(
module(
label = "data source",
server = function(input, output, session, data) {},
ui = function(id, ...) tags$div(p("information about data source")),
datanames = "all"
),
example_module(label = "example teal module"),
module(
"Iris Sepal.Length histogram",
server = function(input, output, session, data) {
output$hist <- renderPlot(
hist(data()[["new_iris"]]$Sepal.Length)
)
},
ui = function(id, ...) {
ns <- NS(id)
plotOutput(ns("hist"))
},
datanames = "new_iris"
)
),
filter = teal_slices(
teal_slice(dataname = "new_iris", varname = "Species"),
teal_slice(dataname = "new_iris", varname = "Sepal.Length"),
teal_slice(dataname = "new_mtcars", varname = "cyl"),
exclude_varnames = list(new_iris = c("Sepal.Width", "Petal.Width")),
module_specific = TRUE,
mapping = list(
`example teal module` = "new_iris Species",
`Iris Sepal.Length histogram` = "new_iris Species",
global_filters = "new_mtcars cyl"
)
),
title = "App title",
header = tags$h1("Sample App"),
footer = tags$p("Sample footer")
)
if (interactive()) {
shinyApp(app$ui, app$server)
}