LimeRick Save

Bridge between LimeSurvey and R (and Shiny)

Project README

LimeRick

Project Status: active CRAN_Status_Badge rstudio mirror downloads

Bridge between R and LimeSurvey by Kamil Wais, Ph. D. (homepage / contact)

The package homepage: http://www.wais.kamil.rzeszow.pl/LimeRick/

The LimeSurvey homepage: http://limesurvey.org

LimeRick: motivation

  • need for a bridge that connects very closely two important open-sorce projects (R and LimeSurvey)
  • need for an advanced tool that allow for:
    • quickly importing responses into R from active on-line surveys
    • automatically accessing properties of survey and questions
    • montoring survey status and responses directly from R
    • adding new responses to a survey directly from R
    • simplifying workflow for reproducible analysis
      (by providing in advance structured data schema)
    • developing data products based on real-time declarative data collection
      (ex. continous on-line tracking studies)
    • collecting meta-data of respondents interactions with on-line surveys
      on unique low-granular level

LimeRick: tutorial

Installing developer version from GitHub

# install.packages('devtools')
devtools::install_github("kalimu/LimeRick")

Loading the installed package

library(LimeRick)
#> 
#> Welcome to LimeRick package version: 0.0.1.9000
#> 
#> Homepage: http://www.wais.kamil.rzeszow.pl/LimeRick
#> 
#> Changelog: news(package = 'LimeRick')
#> Package help: help(LimeRick)
#> 
#> If you find this package useful cite it please. Thank you!
#> See: citation('LimeRick')
#> 
#> To suppress this message use:
#> suppressPackageStartupMessages(library(LimeRick))
#> 
#> First you need to set login parameters and obtain a session key. 
#> See the lsSessionKey() function help page (?lsSessionKey).

Configuring access to a survey

# set link to the LimeSurvey API on the demo remote server
options(lsAPIurl = 'http://odgar.pl/survey/index.php/admin/remotecontrol')

# set LimeSurvey user login data for survey testing purposes
options(lsUser = "LimeRickDemo")
options(lsPass = "LimeRickDemo")

Low-level API function calls vs. function wrappers

# low-level API call
lsAPI(method = "release_session_key")
#> [1] "OK"

# API call using a wrapper function
lsSessionKey("release")
#> Connecting to: http://odgar.pl/survey/index.php/admin/remotecontrol 
#> Releasing session key...
#> [1] "OK"

Setting a connection to a survey

# getting session key for the user and saving it inside a special environment
lsSessionKey("set")
#> Connecting to: http://odgar.pl/survey/index.php/admin/remotecontrol 
#> Obtaining session key...
#> [1] "yagmrycvd49tmim3w4u3n23thimtp952"

# if you work with specific local set it now
Sys.setlocale("LC_ALL", "Polish")
#> [1] "LC_COLLATE=Polish_Poland.1250;LC_CTYPE=Polish_Poland.1250;LC_MONETARY=Polish_Poland.1250;LC_NUMERIC=C;LC_TIME=Polish_Poland.1250"

Listing available surveys

# listing available surveys
(surveyList = lsList("surveys"))
#>      sid                 surveyls_title startdate expires active
#> 1 683736 Feedback survey for R Packages        NA      NA      Y

# extracting ID of demo survey
surveyID = surveyList$sid[1] 

Adding responses via on-line survey questionaire

# try submit your own answers to the demo survey
browseURL(paste0("http://odgar.pl/survey/index.php/survey/index/sid/", surveyID))

or use this link: http://odgar.pl/survey/index.php/survey/index/sid/683736

Listing survey questions

questionList = lsList("questions", surveyID)

Accessing survey or question properites

We can access 22 question properties and 58 survey properties. For example:

# Is the survey active? (Y - Yes)
lsGetProperties('survey', surveyID)$active
#> [1] "Y"

# What is the main text of a given question?
lsGetProperties('question', surveyID, 16)$question
#> [1] "What sector do you represent?"

# Is the question mandatory? (Y - Yes)
lsGetProperties('question', surveyID, 16)$mandatory
#> [1] "N"

Checking survey response

lsGetSummary(surveyID)
#> $completed_responses
#> [1] "619"
#> 
#> $incomplete_responses
#> [1] "46"
#> 
#> $full_responses
#> [1] "665"

Importing responses into R

d = lsGetResponses(surveyID, completionStatus = 'complete')
tail(d)
#>      id          submitdate lastpage startlanguage           startdate
#> 614 661 2016-12-10 08:15:37       NA            en 2016-12-10 08:15:37
#> 615 662 2016-12-10 08:15:39       NA            en 2016-12-10 08:15:39
#> 616 673 2017-01-30 10:05:55        1            en 2017-01-30 10:05:24
#> 617 675 2017-01-30 10:16:08       NA            en 2017-01-30 10:16:08
#> 618 676 2017-01-30 10:17:38       NA            en 2017-01-30 10:17:38
#> 619 680 2017-02-04 12:27:40        1            en 2017-02-04 12:27:39
#>               datestamp   ipaddr packageName
#> 614 2016-12-10 08:15:37             LimeRick
#> 615 2016-12-10 08:15:39             LimeRick
#> 616 2017-01-30 10:05:55 10.0.2.2    LimeRick
#> 617 2017-01-30 10:16:08             LimeRick
#> 618 2017-01-30 10:17:38             LimeRick
#> 619 2017-02-04 12:27:40 10.0.2.2            
#>                                                                                                                                                                                                                                                                                                                                                                                                                 feedback
#> 614                                                                                                                                                                                                                                                                                                                                                                                      Adding feedback directly from R
#> 615                                                                                                                                                                                                                                                                                                                                                                                            Good job! (Kamil, Poland)
#> 616                                                                                                                                                                                                                                                                                                                                                                                                Sounds very promising
#> 617                                                                                                                                                                                                                                                                                                                                                                                      Adding feedback directly from R
#> 618                                                                                                                                                                                                                                                                                                                                                                                         Good job! (Jason, Liverpool)
#> 619 Stress can have an unbelievable impact on health. It can come from a variety of sources and have a diversity of manifestations. The tips that are outlined below will aid in the identification of the factors that cause stress and in the steps that we can take to reduce its impacts or eliminate them entirely. \n \n<a href=https://www.acheterviagrafr24.com/viagra-prix-en-france/>viagra prix en france</a>
#>       sector        country
#> 614 academia         Poland
#> 615 academia         Poland
#> 616 academia United Kingdom
#> 617 academia United Kingdom
#> 618 academia United Kingdom
#> 619            South Africa

Adding responses via R

# showing possible options for a particular question
lsGetAnswerOptions(surveyID, questionID = 16)
#>   answerCode answerText
#> 1         A1    private
#> 2         A2   academia
#> 3         A3        NGO
#> 4         A4 government
#> 5         A5      other

# specifying a response with the use of question code: surveIDXgroupIDXquestionID
response = list('683736X2X27' = "LimeRick",
                '683736X2X26' = "Adding feedback directly from R",
                '683736X2X16' = "A2",# Academia
                '683736X2X21' = "174" # Poland
                )

# adding the above response 
lsAddResponse(surveyID, response)
#> [1] "697"

# or adding via wrapper function
lsAddFeedback(feedback = "Good job! (Kamil, Poland)", 
              sector = "academia", 
              country = "Poland")
#> Thank you for the feedback!
#> [1] "698"

See also:

  • LimeSurvey Project Team / Carsten Schmitz (2015). / LimeSurvey: An Open Source survey tool /LimeSurvey Project Hamburg, Germany. URL http://www.limesurvey.org
Open Source Agenda is not affiliated with "LimeRick" Project. README Source: kalimu/LimeRick
Stars
28
Open Issues
5
Last Commit
6 years ago
Repository

Open Source Agenda Badge

Open Source Agenda Rating