% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/FlattenAnswers.R
\name{FlattenAnswers}
\alias{FlattenAnswers}
\title{Flatten a GetAnswers result into a single data frame.}
\usage{
FlattenAnswers(answers)
}
\arguments{
\item{answers}{The return value of \code{\link{GetAnswers}}: either a plain
\code{data.frame} (simple form) or a list with a main data frame and
nested data frames (form with groups or multivalued fields).}
}
\value{
A single \code{data.frame}. For simple forms the columns keep their
  original names. For forms with groups, main-frame columns are prefixed
  with \code{"answer."} and nested-frame columns are prefixed with their
  group \code{componentId}.
}
\description{
Converts the output of \code{\link{GetAnswers}} into a single flat
\code{data.frame}. Works with any form: if the form is simple (no groups or
multivalued fields), \code{GetAnswers} already returns a plain
\code{data.frame} and this function returns it unchanged. For forms with
groups or multivalued fields, the main data frame and all nested data frames
are joined using \code{dplyr::full_join}.
}
\details{
When the form contains multivalued groups or fields, each submission may
produce multiple rows in the nested data frames. Joining them to the main
data frame causes \strong{row duplication}: each combination of main row
and nested row is represented. Account for this in any aggregation.
}
\examples{
\donttest{
answers <- GetAnswers("cizio7xeohwgc8k4g4koo008kkoocwg", 5719)
FlattenAnswers(answers)

# Pipe-friendly
GetAnswers("cizio7xeohwgc8k4g4koo008kkoocwg", 5719) |> FlattenAnswers()
}

}
