FlattenAnswers: Flatten a GetAnswers result into a single data frame.

View source: R/FlattenAnswers.R

FlattenAnswersR Documentation

Flatten a GetAnswers result into a single data frame.

Description

Converts the output of GetAnswers into a single flat data.frame. Works with any form: if the form is simple (no groups or multivalued fields), GetAnswers already returns a plain 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 dplyr::full_join.

Usage

FlattenAnswers(answers)

Arguments

answers

The return value of GetAnswers: either a plain data.frame (simple form) or a list with a main data frame and nested data frames (form with groups or multivalued fields).

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 row duplication: each combination of main row and nested row is represented. Account for this in any aggregation.

Value

A single data.frame. For simple forms the columns keep their original names. For forms with groups, main-frame columns are prefixed with "answer." and nested-frame columns are prefixed with their group componentId.

Examples


answers <- GetAnswers("cizio7xeohwgc8k4g4koo008kkoocwg", 5719)
FlattenAnswers(answers)

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



RColetum documentation built on April 17, 2026, 1:07 a.m.