Learn R Programming

Rmonkey (version 0.3.1)

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

Description

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

Usage

"as.data.frame"(x, row.names, optional, details = NULL, stringsAsFactors = FALSE, ...) "as.data.frame"(x, row.names, optional, details = NULL, stringsAsFactors = FALSE, ...)

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.
stringsAsFactors
Whether to create factor variables when creating the resulting data.frame. There should be no situation where this needs to be TRUE.
...
Other arguments. Currently ignored.

Value

question_id numbers. Question wordings are stored in a “question” attribute in each variable. The question wordings can also be extracted from a “sm_surveydetails” object using surveyquestions. 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)
# ## End(Not run)

Run the code above in your browser using DataLab