% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/analyze.R
\name{summarize_survey}
\alias{summarize_survey}
\title{Summarize Survey Questions}
\usage{
summarize_survey(
  survey,
  scale_points,
  questions = "all",
  emp_id_col = NULL,
  plot = FALSE
)
}
\arguments{
\item{survey}{A glint_survey object or data frame containing survey data}

\item{scale_points}{Integer specifying the number of scale points (2-11)}

\item{questions}{Character vector of question text(s) to analyze, or "all" to
analyze all questions (default: "all")}

\item{emp_id_col}{Character string specifying the employee ID column name}

\item{plot}{Logical. If \code{TRUE}, prints a favorability stacked bar chart
sorted by Glint Score and returns the data invisibly. Requires
\pkg{ggplot2}. Default: \code{FALSE}.}
}
\value{
A tibble with one row per question containing:
\describe{
\item{question}{The question text}
\item{mean}{Mean of numeric responses (raw scale)}
\item{sd}{Standard deviation of numeric responses}
\item{glint_score}{Mean transformed to a 0-100 scale, matching the score
displayed in the Viva Glint UI: \code{round(((mean - 1) / (scale_points - 1)) * 100)}}
\item{n_responses}{Count of non-blank, non-null responses}
\item{n_skips}{Count of blank or null responses}
\item{n_total}{Total number of respondents}
\item{pct_favorable}{Percentage of responses classified as favorable}
\item{pct_neutral}{Percentage of responses classified as neutral}
\item{pct_unfavorable}{Percentage of responses classified as unfavorable}
}
When \code{plot = TRUE}, the same tibble is returned invisibly after
printing the plot.
}
\description{
Calculates comprehensive metrics for survey questions, returning a summary
analysis in tidy format. This includes mean, standard deviation, Glint Score,
response counts, skip counts, and favorability percentages.
}
\examples{
survey_path <- system.file("extdata", "survey_export.csv", package = "vivaglint")
survey <- read_glint_survey(survey_path, emp_id_col = "EMP ID")

# Summarize all questions (5-point scale)
summary <- summarize_survey(survey, scale_points = 5)

# Summarize specific questions
summary_subset <- summarize_survey(survey, scale_points = 5,
  questions = c("My work is meaningful", "I feel valued"))

# With favorability chart
if (requireNamespace("ggplot2", quietly = TRUE)) {
  summarize_survey(survey, scale_points = 5, plot = TRUE)
}
}
