Learn R Programming

Rmonkey (version 0.3.1)

getresponses: Get responses

Description

Get responses for a survey

Usage

getresponses(respondents, survey, api_key = getOption('sm_api_key'), oauth_token = getOption('sm_oauth_token'), ...)
getallresponses(survey, api_key, oauth_token, wait = 0, ...)

Arguments

respondents
A vector containing up to 100 respondent ID numbers, possibly returned by respondentlist.
survey
A Survey Monkey survey ID number (or an object of class “sm_survey” from which it can be extracted), possibly returned by surveylist.
api_key
Your API key. By default, retrieved from getOption('sm_api_key').
oauth_token
Your OAuth 2.0 token, as generated by smlogin. By default, retrieved from getOption('sm_oauth_token').
wait
A time, in seconds, to wait between API calls. This can be used to throttle API request in order to avoid going over limits.
...
Other arguments passed to POST.

Value

For getresponses(), a list (of class sm_response_list) containing one or more objects of class sm_response.For getallresponses(), a data.frame.

Details

Retrieves response data for requested respondents to a specified survey. getresponses() retrieves a list structure that can be further parsed using an as.data.frame method. getallresponses() returns a data.frame of all responses for a survey automatically using just the survey ID.

Note: Text responses returned are truncated after 32,768 characters.

Note: Surveys with over 500,000 responses are not available via the API currently.

References

https://developer.surveymonkey.com/mashery/get_responses

Examples

Run this code
## Not run: 
# smlogin()
# s <- surveylist()
# r <- respondentlist(s[[1]])
# 
# # get one response
# getresponses(r[[1]], s[[1]])
# 
# # get all responses (up to 100)
# g <- getresponses(r, s[[1]])
# as.data.frame(g) # convert to data.frame
# ## End(Not run)

Run the code above in your browser using DataLab