Learn R Programming

Rmonkey (version 0.2)

as.data.frame.sm_response: Parse responses to dataframe

Description

Parse responses to a data.frame using a sm_surveydetails object.

Usage

# S3 method for sm_response
as.data.frame(x, row.names, optional, details = NULL, …)
# S3 method for sm_response_list
as.data.frame(x, row.names, optional, details = NULL, …)

Arguments

x

An object of class sm_response or sm_response_list.

row.names

Ignored.

optional

Ignored.

details

If NULL, the method looks for a “survey_id” attribute in x. Otherwise, details must be supplied as an object of class sm_surveydetails or a survey ID number (possibly returned by surveylist). The first and third of these possibilities will trigger (and therefore require) a surveydetails request.

Other arguments. Currently ignored.

Value

A data.frame. Variable names are based upon the Survey Monkey internal question_id numbers. Question wordings are stored in a “question” attribute in each variable. The user will have to manually rename variables.

Details

Parses an sm_response object, or list of such objects, into a dataframe using a sm_surveydetails object to structure the result.

Examples

Run this code
# NOT RUN {
smlogin()
s <- surveylist()
r <- respondentlist(s[[1]])

# get all responses (up to 100)
a <- getresponses(lapply(r[[1]], function(x) `[`, 'respondent_id'), s[[1]])
as.data.frame(a)
# }

Run the code above in your browser using DataLab