# general data example
data <- teal_data()
data <- within(data, {
CO2 <- CO2
})
app <- init(
data = data,
modules = modules(
tm_rmarkdown(
label = "RMarkdown Module",
rmd_content = c(
"---",
"title: \"R Markdown Report\"",
"output: html_document",
"---",
"",
"```{r}",
"summary(CO2) |> print()",
"```"
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
nrow_transform <- teal_transform_module(
label = "N Rows selector",
ui = function(id) {
ns <- NS(id)
tags$div(
numericInput(ns("n_rows"), "Show n rows", value = 40, min = 0, max = 200, step = 5)
)
},
server = function(id, data) {
moduleServer(id, function(input, output, session) {
reactive({
req(data())
within(data(),
{
n_rows <- n_rows_value
},
n_rows_value = input$n_rows
)
})
})
}
)
app <- init(
data = data,
modules = modules(
tm_rmarkdown(
label = "RMarkdown Module",
rmd_content = readLines(
system.file(
file.path("sample_files", "co2_example.Rmd"),
package = "teal.modules.general"
)
),
allow_download = FALSE,
extra_transform = list(nrow_transform)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}
Run the code above in your browser using DataLab