Skip to contents

Server logic for the shiny module to work together with narratorUI

Usage

narratorServer(
  id,
  df,
  narrative_type = "descriptive",
  summarization = "sum",
  ...
)

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

Value

Narrative output

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)