run_analysis_plan: Run a pre-planned analysis from an instrument's analysis plan

View source: R/analysis_plan.R

run_analysis_planR Documentation

Run a pre-planned analysis from an instrument's analysis plan

Description

Executes every analysis block defined in the instrument's analysis_plan slot against the supplied response data. Each block corresponds to one research question defined during instrument design in the SurveyBuilder. Results include APA-formatted statistics, effect sizes, interpretation prompts, and reporting references.

Usage

run_analysis_plan(
  data,
  instrument,
  scored = TRUE,
  plots = FALSE,
  plot_palette = c("web", "print")
)

Arguments

data

A tibble or data.frame of responses, typically produced by read_responses() or read_sheet_responses().

instrument

An sframe object containing an analysis_plan.

scored

Logical. Whether to automatically score scales before running the analysis. Defaults to TRUE.

plots

Logical. When TRUE and ggplot2 is installed, supported blocks gain a ⁠$plot⁠ element holding a brand-styled ggplot object: bar charts for frequency and chi-square blocks, scatter plots with a regression overlay for correlation and linear-regression blocks. Defaults to FALSE.

plot_palette

One of "web" (brand colours, for on-screen use) or "print" (black, grey, and white, for journal-ready print figures). Applied to every plot attached when plots = TRUE. See sframe_brand().

Value

An object of class sframe_analysis_results, a list with one element per analysis block. Each element contains the test result, APA string, interpretation prompt, and reporting-reference metadata. Inferential blocks also carry a ⁠$table⁠ data frame suitable for knitr::kable(). Pass to render_results() to generate a formatted report.

See Also

render_results(), read_sheet_responses()

Examples

instr <- read_sframe(
  system.file("extdata", "tourism_services_demo.sframe",
              package = "surveyframe")
)
responses <- read_responses(
  system.file("extdata", "tourism_services_responses.csv",
              package = "surveyframe"),
  instr,
  respondent_id = "respondent_id",
  submitted_at = "submitted_at",
  meta_cols = "started_at"
)

results <- run_analysis_plan(responses, instr)
print(results)


surveyframe documentation built on July 25, 2026, 1:07 a.m.