% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reshape.R
\name{pivot_long}
\alias{pivot_long}
\title{Pivot Survey Data to Long Format}
\usage{
pivot_long(
  survey,
  data_type = "all",
  include_empty = FALSE,
  include_standard_cols = TRUE
)
}
\arguments{
\item{survey}{A glint_survey object or data frame containing survey data}

\item{data_type}{Character string indicating what data to return: "all" for all
responses including those without comments, "comments" for only responses with
comments, or "both" for separate tibbles (default: "all")}

\item{include_empty}{Logical indicating whether to include empty comments when
data_type = "comments" (default: FALSE)}

\item{include_standard_cols}{Logical indicating whether to include standard
columns (EMP ID, Manager ID, etc.) in the output (default: TRUE)}
}
\value{
When \code{data_type = "all"} or \code{"comments"}, a single tibble
in long format with columns:
\describe{
\item{Standard columns}{EMP ID, First Name, Last Name, etc. (if
\code{include_standard_cols = TRUE})}
\item{question}{The question text}
\item{response}{Numeric response value}
\item{comment}{Comment text (NA if not provided)}
\item{comment_topics}{Comma-separated topic tags (NA if not provided)}
\item{sensitive_flag}{Sensitivity flag value}
}
When \code{data_type = "both"}, a named list with two elements:
\describe{
\item{all}{Long-format tibble of all responses (same structure as above)}
\item{comments}{Long-format tibble filtered to rows with non-empty comments}
}
}
\description{
Transforms survey data from wide format (one row per respondent) to long format
(one row per respondent-question combination). Can return all responses, only
comments, or both depending on the data_type parameter.
}
\examples{
survey_path <- system.file("extdata", "survey_export.csv", package = "vivaglint")
survey <- read_glint_survey(survey_path, emp_id_col = "EMP ID")

# Get all responses (with and without comments)
all_data <- pivot_long(survey)

# Get only responses with comments
comments_only <- pivot_long(survey, data_type = "comments")

# Get both separately
both <- pivot_long(survey, data_type = "both")
all_responses <- both$all
comments <- both$comments
}
