Server logic for the shiny module to work together with narratorUI
Arguments
- id
Namespace specification
- df
Reactive data frame
- narrative_type
Type of narrative 'descriptive', 'trend' or 'forecast'
- summarization
Summarization/aggregation for the data - 'sum', 'count' or 'average'
- ...
Additional arguments for
narrate_*
functions
Examples
library(shiny)
library(narrator)
library(dplyr)
df <- sales %>%
group_by(Region, Product) %>%
summarise(Sales = sum(Sales, na.rm = TRUE))
ui <- fluidPage(
narratorUI(id = "main")
)
server <- function(input, output, session) {
narratorServer(
id = "main",
df = reactive(df),
format = TRUE,
summarization = "sum")
}
if (interactive()) shinyApp(ui, server)