## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
# Every suggested package the chunks below reach. A deck that carries a table
# goes through flextable, and the driver model through rwa, so officer alone
# is not enough to know a chunk can run.
has_officer <- requireNamespace("officer", quietly = TRUE)
has_flextable <- requireNamespace("flextable", quietly = TRUE)
has_rwa <- requireNamespace("rwa", quietly = TRUE)
can_table <- has_officer && has_flextable
can_model <- can_table && has_rwa

## ----setup--------------------------------------------------------------------
library(ezrsurvey)

## -----------------------------------------------------------------------------
deck_dir <- tempdir()

## ----eval = can_table---------------------------------------------------------
report_deck(
  list(
    "Who follows pod racing?" = plot_bars(
      calc_percentage(podracing_survey, demo_gender)),
    "How likely are they to recommend it?" = calc_nps(
      podracing_survey, nps_value)
  ),
  path = file.path(deck_dir, "overview.pptx"),
  title = "Pod-Racing Fan Survey"
)

## ----eval = can_model---------------------------------------------------------
drivers <- ipm_model(podracing_survey, nps_value, "ratings_")

report_new("pptx") %>%
  report_title_slide(
    "Pod-Racing Fan Survey",
    subtitle = "1,000 fans | Fieldwork 2026"
  ) %>%
  report_section("RECOMMENDATION") %>%
  report_slide("How likely are you to recommend pod racing?",
               plot_nps(podracing_survey, nps_value)) %>%
  report_section("RATINGS") %>%
  report_slide("Which aspects matter most, and which fall short?",
               plot_ipm(drivers)) %>%
  report_add_slide("What we should fix first") %>%
  report_add_text(c(
    "Value and commentary sit lowest and matter most.",
    "Atmosphere is already strong; further gains there move nothing."
  )) %>%
  report_save(file.path(deck_dir, "deck.pptx"))

## ----eval = can_model---------------------------------------------------------
report_new("docx") %>%
  report_section("Pod-Racing Fan Survey") %>%
  report_add_text("Net Promoter Score and the drivers behind it.") %>%
  report_add_table(drivers) %>%
  report_save(file.path(deck_dir, "report.docx"))

## -----------------------------------------------------------------------------
use_brand(colors = c("#0B5394", "#E69138"), fonts = "Georgia", quiet = TRUE)
pal_brand()
clear_brand()

## ----eval = has_officer-------------------------------------------------------
report_layouts()

