Learn R Programming

rsurveycto (version 0.2.5)

scto_get_form_responses: Read form data from a SurveyCTO server and convert to long format

Description

This function converts data from scto_read() to long format, then joins the data with the "survey" and "choices" components of the form metadata.

Usage

scto_get_form_responses(
  auth,
  form_id,
  id_cols = c("KEY", "formdef_version", "CompletionDate", "SubmissionDate", "starttime",
    "endtime", "review_status", "review_quality"),
  exclude_cols = "instanceID",
  ...
)

Value

A data.table with one row per response, i.e., one row per form submission per field. If necessary to avoid ambiguity, columns from the "survey" part of the form definition are prefixed with field_, while columns from the "choices" part of the form definition are prefixed with choice_. Original column names from data returned by scto_read() are in the submission_field_name column, while corresponding values are in the field_value column. Data can be converted back to wide format as desired using data.table::dcast() or tidyr::pivot_wider().

Arguments

auth

scto_auth() object.

form_id

String indicating id of the form.

id_cols

Character vector of data columns to keep in the result, will be passed as id.vars to data.table::melt().

exclude_cols

Character vector of data columns to exclude from the result.

...

Additional arguments passed to scto_read().

Examples

Run this code
if (FALSE) {
auth = scto_auth('scto_auth.txt')
responses = scto_get_form_responses(auth, 'my_form')
}

Run the code above in your browser using DataLab