getresponses: Get responses

Description Usage Arguments Details Value Author(s) References Examples

Description

Get responses for a survey

Usage

1
2
3
4
5
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. If missing, the function will try to find an appropriate value in respondents.

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.

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.

Value

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

For getallresponses(), a data.frame.

Author(s)

Thomas J. Leeper

References

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
smlogin()
s <- surveylist()
r <- respondentlist(s[[1]])

# get one response
getresponses(r[[1]])

# get all responses (up to 100)
g <- getresponses(r)
as.data.frame(g) # convert to data.frame

## End(Not run)

cloudyr/Rmonkey documentation built on May 13, 2019, 8:17 p.m.