| Title: | Working with 'LimeSurvey' Surveys and Responses |
|---|---|
| Description: | 'LimeSurvey' is Free/Libre Open Source Software for the development and administrations of online studies, using sophisticated tailoring capabilities to support multiple study designs (see <https://www.limesurvey.org>). This package supports programmatic creation of surveys that can then be imported into 'LimeSurvey', as well as user friendly import of responses from 'LimeSurvey' studies. |
| Authors: | Gjalt-Jorn Peters [aut, cre] (ORCID: <https://orcid.org/0000-0002-0336-9589>), Andrew Heiss [aut] (ORCID: <https://orcid.org/0000-0002-3948-3914>), Urs Wilke [aut] (ORCID: <https://orcid.org/0000-0001-7257-2524>) |
| Maintainer: | Gjalt-Jorn Peters <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 25.5.5 |
| Built: | 2026-05-26 08:21:36 UTC |
| Source: | https://github.com/cran/limonaid |
Working With LimeSurvey Surveys and Responses
LimeSurvey is Free/Libre Open Source Software for the development and administrations of online studies, using sophisticated tailoring capabilities to support multiple study designs. This package supports programmatic creation of surveys that can then be imported into LimeSurvey, as well as userfriendly import of responses from LimeSurvey studies.
Gjalt-Jorn Peters [email protected]
Useful links:
This is a convenience function that allows you to add an answer option to a question object.
add_answer_option_to_question(question, ...)add_answer_option_to_question(question, ...)
question |
The limonaid Question object |
... |
Options that are passed on to the Question's |
The question object.
myQuestion <- limonaid::Question$new( code = 'myQuestion', type='radio' ) |> add_answer_option_to_question( code = 1, optionTexts = "First option" ) |> add_answer_option_to_question( code = 2, optionTexts = "Second option" );myQuestion <- limonaid::Question$new( code = 'myQuestion', type='radio' ) |> add_answer_option_to_question( code = 1, optionTexts = "First option" ) |> add_answer_option_to_question( code = 2, optionTexts = "Second option" );
This is used when creating dataframes for TSV exports.
append_lsdf_rows(data, row)append_lsdf_rows(data, row)
data |
The first dataframe. |
row |
The second dataframe. |
A merged dataframe.
limonaid::append_lsdf_rows(mtcars, iris);limonaid::append_lsdf_rows(mtcars, iris);
The cat0 function is to cat what paste0 is to paste; it simply makes concatenating many strings without a separator easier.
cat0(..., sep = "")cat0(..., sep = "")
... |
The character vector(s) to print; passed to cat. |
sep |
The separator to pass to cat, of course, |
Nothing (invisible NULL, like cat).
cat0("The first variable is '", names(mtcars)[1], "'.");cat0("The first variable is '", names(mtcars)[1], "'.");
This function efficiently checks for the presence of a package
without loading it (unlike library() or require().
This is useful to force yourself to use the package::function
syntax for addressing functions; you can make sure required packages
are installed, but their namespace won't attach to the search path.
checkPkgs( ..., install = FALSE, load = FALSE, repos = "https://cran.rstudio.com" )checkPkgs( ..., install = FALSE, load = FALSE, repos = "https://cran.rstudio.com" )
... |
A series of packages. If the packages are named, the names are the package names, and the values are the minimum required package versions (see the second example). |
install |
Whether to install missing packages from |
load |
Whether to load packages (which is exactly not the point of this function, but hey, YMMV). |
repos |
The repository to use if installing packages; default is the RStudio repository. |
Invisibly, a vector of the available packages.
limonaid::checkPkgs('base'); ### Require a version limonaid::checkPkgs(limonaid = "0.2.0"); ### This will show the error message tryCatch( limonaid::checkPkgs( base = "99", stats = "42.5", ufs = 20 ), error = print );limonaid::checkPkgs('base'); ### Require a version limonaid::checkPkgs(limonaid = "0.2.0"); ### This will show the error message tryCatch( limonaid::checkPkgs( base = "99", stats = "42.5", ufs = 20 ), error = print );
Tries to 'smartly' convert factor and character vectors to numeric.
convertToNumeric(vector, byFactorLabel = FALSE)convertToNumeric(vector, byFactorLabel = FALSE)
vector |
The vector to convert. |
byFactorLabel |
When converting factors, whether to do this
by their label value ( |
The converted vector.
convertToNumeric(as.character(1:8));convertToNumeric(as.character(1:8));
This function is used by append_lsdf_rows(), and you normally
should not use it directly.
emptyDf(colnames, nrow, fillWith = "")emptyDf(colnames, nrow, fillWith = "")
colnames |
The column names for the dataframe. |
nrow |
The number of rows. |
fillWith |
What to fill the dataframe with. |
The data.frame.
limonaid::emptyDf(c("x", "y"), 3);limonaid::emptyDf(c("x", "y"), 3);
Sometimes it is useful to export a version of a survey with a different primary language, and/or less additional languages. This function allows that.
export_with_languages( x, language, path, additional_languages = NULL, new_sid = x$sid, backupLanguage = x$language, prefix = "limesurvey--", suffix = "", parallel = TRUE )export_with_languages( x, language, path, additional_languages = NULL, new_sid = x$sid, backupLanguage = x$language, prefix = "limesurvey--", suffix = "", parallel = TRUE )
x |
The Survey object. |
language |
The desired primary language. |
path |
The path where to save the .TSV file. |
additional_languages |
If specified, the selection of additional
languages. If not specified, the survey's primary language will just be
switched to |
new_sid |
If specified, a new sid to use. |
backupLanguage |
The language to use if an element is not specified in one of the languages. |
prefix |
The prefix to use in the filename. |
suffix |
The suffix to use in the filename. |
parallel |
Whether to use multiple cores when exporting the survey. |
Invisibly, the cloned and altered survey object.
### Add later### Add later
This function logs into the LimeSurvey API and provides an access session key. It was adapted by Gjalt-Jorn Peters from a function originally written by Andrew Heiss.
get_session_key( username = getOption("lime_username"), password = getOption("lime_password"), hostname = getOption("lime_api") )get_session_key( username = getOption("lime_username"), password = getOption("lime_password"), hostname = getOption("lime_api") )
username |
LimeSurvey username.
Defaults to value set in |
password |
LimeSurvey password.
Defaults to value set in |
hostname |
The host to use (if not using the one specified in
the options). If no hostname is specified in the |
API token
## Not run: get_session_key() ## End(Not run)## Not run: get_session_key() ## End(Not run)
R6 Class representing a LimeSurvey group
R6 Class representing a LimeSurvey group
A group is mostly just a container for questions.
group_nameThe group name / title / label
descriptionThe group description
grelevanceThe relevance equation for the group
group_orderThe group order (in the survey)
randomization_groupThe randomization group (that the group is a part of)
languageThe language of the group; or primary language, if there are multiple languages.
additional_languagesAny additional languages for the title and description elements.
idThe identifier of the group (a unique number in a survey)
sidThe identifier of the survey that this group belongs to
otherOptionsAny additional options, stored as a named list
by assigning as.list(...).
questionsThe questions in this group
new()
Create a new group object. Most of this text comes directly from the TSV manual page at https://www.limesurvey.org/manual/Tab_Separated_Value_survey_structure, so please see that page for more details.
Group$new( group_name = "", description = "", grelevance = 1, group_order = 1, randomization_group = NULL, language = "en", additional_languages = "", id = NULL, sid = NULL, new_id_fun = NULL, uqid = NULL, repo_url = "https://operationalizations.com/questionnaires/json", ... )
group_nameThe title of the group (if there are multiple languages, a named vector where every element is the title in another language and every element's name is the language code).
descriptionThe description of the group (if there are multiple languages, a named vector where every element is the title in another language and every element's name is the language code).
grelevanceThe group's relevance equation
group_orderThe group order (if the group is part of a survey)
randomization_groupThe group's randomization group
languageThe group's only or primary language
additional_languagesAny additional languages
idOptionally, the id of the group.
sidOptionally, the identifier of the survey that this group belongs to.
new_id_funA function to set identifiers (for XML exports, which mirrors MySQL tables and so needs identifiers). By default, new question objects receive this function from the group containing them; and groups receive it from the survey containing them. This ensures that identifiers are always unique in a survey (despite question objects not being able to 'see' anything in the group containing them, and group objects not being able to 'see' anything in the survey containing them; because they 'received' this function from the parent object, and it 'bubbles down' through groups to the questions, those functions still get and set a private identifier property in the 'top-most' object).
uqidA Unique Questionnaire Identifier (UQID) to import a questionnaire and populate the group with it.
repo_urlThe URL to a repo serving the questionnaire with the UQID in JSON.
...Any additional options, stored as a named list in the
otherOptions property by assigning as.list(...).
A new Group object.
add_question()
Add a question to a group object.
Group$add_question( code, type = NULL, lsType = NULL, question_order = NULL, ... )
codeThe question code.
typeThe question type.
lsTypeThe question type, as LimeSurvey question type.
question_orderThe question order; automatically filled if left empty; starts counting at 0.
...Additional arguments are used to create the Question using
Question$new.
Invisibly, the thisQuestion object that was just added. Note
that you can further modify this, which will modify the question object
"in" the survey group as well. This allows you to pipe the question
creation on to, for example, add answer options.
export_to_lsg()
Export the group as an LSG (xml) file.
Group$export_to_lsg(
file = NULL,
preventOverwriting = limonaid::opts$get("preventOverwriting"),
encoding = limonaid::opts$get("encoding"),
silent = limonaid::opts$get("silent"),
backupLanguage = self$language
)fileThe filename to which to save the file.
preventOverwritingWhether to prevent overwriting.
encodingThe encoding to use
silentWhether to be silent or chatty.
backupLanguageThe language to get content from if not from the primary langage.
parallelWhether to work serially or in parallel.
Invisibly, the Survey object.
clone()
The objects of this class are cloneable with this method.
Group$clone(deep = FALSE)
deepWhether to make a deep clone.
myGroup <- limonaid::Group$new( group_name = "My Group" ); myGroup$add_question( "testQuestion1", questionTexts = "First question", type="free text (short)" ); myGroup$add_question( "testQuestion2", questionTexts = "Second question", type="radio" ); myGroup$questions$testQuestion2$add_answer_option( "option1", "First option" ); myGroup$questions$testQuestion2$add_answer_option( "option2", "Second option" ); cat(as.character(myGroup$export_to_lsg()));myGroup <- limonaid::Group$new( group_name = "My Group" ); myGroup$add_question( "testQuestion1", questionTexts = "First question", type="free text (short)" ); myGroup$add_question( "testQuestion2", questionTexts = "Second question", type="radio" ); myGroup$questions$testQuestion2$add_answer_option( "option1", "First option" ); myGroup$questions$testQuestion2$add_answer_option( "option2", "Second option" ); cat(as.character(myGroup$export_to_lsg()));
This function converts raw base64 results into a data frame. It was adapted by Gjalt-Jorn Peters from a function originally written by Andrew Heiss.
limer_base64_to_df( x, encoding = NULL, iconvArgs = list(from = "UTF-8", to = "UTF-8") )limer_base64_to_df( x, encoding = NULL, iconvArgs = list(from = "UTF-8", to = "UTF-8") )
x |
... |
encoding |
Either |
iconvArgs |
Arguments to pass to [base::iconv(). |
## Not run: limer_base64_to_df() ## End(Not run)## Not run: limer_base64_to_df() ## End(Not run)
This function makes a generic call to the LimeSurvey API. See https://www.limesurvey.org/manual/RemoteControl_2_API for API documentation. It was adapted by Gjalt-Jorn Peters from a function originally written by Andrew Heiss.
limer_call_limer(method, params = list(), ..., encoding = "utf-8")limer_call_limer(method, params = list(), ..., encoding = "utf-8")
method |
API function to call. Full lis Defaults to value set in |
params |
Optional named list of parameters to pass to the function. |
... |
Other arguments passed to |
encoding |
The encoding to use |
Results from the API (sometimes plain text, sometimes base64-encoded text).
## Not run: limer_call_limer(method = "list_surveys") limer_call_limer(method = "get_summary", params = list(iSurveyID = 238481, sStatname = "completed_responses")) ## End(Not run)## Not run: limer_call_limer(method = "list_surveys") limer_call_limer(method = "get_summary", params = list(iSurveyID = 238481, sStatname = "completed_responses")) ## End(Not run)
This function exports and downloads a participant property from a LimeSurvey survey. It was adapted by Gjalt-Jorn Peters from a function originally written by Andrew Heiss.
limer_get_participant_property( iSurveyID, aTokenQueryProperties, aTokenProperties )limer_get_participant_property( iSurveyID, aTokenQueryProperties, aTokenProperties )
iSurveyID |
... |
aTokenQueryProperties |
... |
aTokenProperties |
... |
## Not run: limer_get_participant_property( iSurveyID = 12345, aTokenQueryProperties = 1, aTokenProperties = list("attribute_1") ); ## End(Not run)## Not run: limer_get_participant_property( iSurveyID = 12345, aTokenQueryProperties = 1, aTokenProperties = list("attribute_1") ); ## End(Not run)
This function exports and downloads the list of participants from a LimeSurvey survey.
limer_get_participants(iSurveyID, iStart, iLimit, bUnused, aAttributes)limer_get_participants(iSurveyID, iStart, iLimit, bUnused, aAttributes)
iSurveyID |
... |
iStart |
... |
iLimit |
... |
bUnused |
... |
aAttributes |
... |
## Not run: limer_get_participants(12345, iStart=1, iLimit=10, bUnused=FALSE, aAttributes=c('attribute_1','attribute_2')) limer_get_participants(12345, iStart=1, iLimit=10, bUnused=FALSE, aAttributes=FALSE) ## End(Not run)## Not run: limer_get_participants(12345, iStart=1, iLimit=10, bUnused=FALSE, aAttributes=c('attribute_1','attribute_2')) limer_get_participants(12345, iStart=1, iLimit=10, bUnused=FALSE, aAttributes=FALSE) ## End(Not run)
This function exports and downloads data from a LimeSurvey survey. It was adapted by Gjalt-Jorn Peters from a function originally written by Andrew Heiss.
limer_get_responses( iSurveyID, sDocumentType = "csv", sLanguageCode = NULL, sCompletionStatus = "complete", sHeadingType = "code", sResponseType = "long", encoding_limerCall = NULL, encoding_txtCon = NULL, ... )limer_get_responses( iSurveyID, sDocumentType = "csv", sLanguageCode = NULL, sCompletionStatus = "complete", sHeadingType = "code", sResponseType = "long", encoding_limerCall = NULL, encoding_txtCon = NULL, ... )
iSurveyID |
The LimeSurvey survey identifier (the |
sDocumentType |
... |
sLanguageCode |
... |
sCompletionStatus |
... |
sHeadingType |
... |
sResponseType |
... |
encoding_limerCall |
The encoding to pass to
the |
encoding_txtCon |
The encoding to pass to
|
... |
Further arguments to |
## Not run: limer_get_responses(12345) ## End(Not run)## Not run: limer_get_responses(12345) ## End(Not run)
This function clears the LimeSurvey API session key currently in use, effectively logging out. This function was adapted by Gjalt-Jorn Peters from a function originally written by Andrew Heiss.
limer_release_session_key()limer_release_session_key()
## Not run: limesurvey::limer_release_session_key() ## End(Not run)## Not run: limesurvey::limer_release_session_key() ## End(Not run)
To use this function, you need to setup R for the LimeSuevey API, as
described in vignette("limesurvey_api_setup").
limer_upload_tsv_to_limesurvey( ls_txt_path, open_url = "preview", hostname = getOption("lime_api") )limer_upload_tsv_to_limesurvey( ls_txt_path, open_url = "preview", hostname = getOption("lime_api") )
ls_txt_path |
Path of the limesurvey text file |
open_url |
Character vector containing one or more of the strings in
|
hostname |
The host to use (if not using the one specified in
the options). If no hostname is specified in the |
The value of the id of your survey in the specified LimeSurvey installation,
## Not run: ### Log into the LimeSurvey API: limonaid::get_session_key(); ### Upload a tab separated values file: limer_upload_tsv_to_limesurvey( "PATH/TO/YOUR/LIMESURVEY/TXT FILE", c("preview", "survey") ); ## End(Not run)## Not run: ### Log into the LimeSurvey API: limonaid::get_session_key(); ### Upload a tab separated values file: limer_upload_tsv_to_limesurvey( "PATH/TO/YOUR/LIMESURVEY/TXT FILE", c("preview", "survey") ); ## End(Not run)
This function applies specific code bits from the LimeSurvey data
import R script, read by ls_parse_data_import_script(), for example
to update variable names, set labels, etc.
ls_apply_script_bits( data, scriptBits, setVarNames = TRUE, setLabels = TRUE, convertToCharacter = FALSE, convertToFactor = FALSE, categoricalQuestions = NULL, massConvertToNumeric = TRUE, silent = limonaid::opts$get("silent"), sticky = limonaid::opts$get("sticky") )ls_apply_script_bits( data, scriptBits, setVarNames = TRUE, setLabels = TRUE, convertToCharacter = FALSE, convertToFactor = FALSE, categoricalQuestions = NULL, massConvertToNumeric = TRUE, silent = limonaid::opts$get("silent"), sticky = limonaid::opts$get("sticky") )
data |
The dataframe. |
scriptBits |
The object returned by the call
to |
setVarNames, setLabels, convertToCharacter, convertToFactor
|
Whether to set variable names or labels, or convert to character or factor, using the code isolated using the specified regular expression. |
categoricalQuestions |
Which variables (specified using LimeSurvey variable names) are considered categorical questions; for these, the script to convert the variables to factors, as extracted from the LimeSurvey import file, is applied. |
massConvertToNumeric |
Whether to convert all variables to numeric
using |
silent |
Whether to be silent or verbose ('chatty'). |
sticky |
Whether to make labels sticky (requires the |
The dataframe.
These are a set of really basic functions that facilitate building LimeSurvey Expression Manager (LSEM) equations.
ls_eq_build(lhs, operator, rhs) ls_eq_is(varCode, value, naok = TRUE) ls_eq_isChecked(varCode, naok = TRUE) ls_eq_isUnchecked(varCode, naok = TRUE) ls_eq_if(cond, ifExpr, elseExpr) ls_eq_ifRegex(regex, varCode, ifExpr, elseExpr, naok = TRUE) ls_eq_brace(expr) ls_eq_quote(expr)ls_eq_build(lhs, operator, rhs) ls_eq_is(varCode, value, naok = TRUE) ls_eq_isChecked(varCode, naok = TRUE) ls_eq_isUnchecked(varCode, naok = TRUE) ls_eq_if(cond, ifExpr, elseExpr) ls_eq_ifRegex(regex, varCode, ifExpr, elseExpr, naok = TRUE) ls_eq_brace(expr) ls_eq_quote(expr)
lhs |
The left-hand side expression. |
operator |
The operator. |
rhs |
The right-hand side expression. |
varCode |
A LimeSurvey variable code. |
value |
A value. |
naok |
Whether to append ".NAOK" to the variable code. |
cond |
A condition, for example created by |
ifExpr, elseExpr, expr
|
An expression. |
regex |
A regular expression. |
ls_eq_build() just pastes together its three
arguments in the same order using a space as
separator. So it's mostly used for clarity when
building LSEM equations.
ls_eq_is() uses ls_eq_build() to specify a logical
expression that is true when varCode equals value.
ls_eq_if() builds an if/then/else expression; if
cond evaluates to TRUE, the LSEM uses ifExpr;
otherwise, it uses elseExpr.
ls_eq_ifRegex checks a question against a regular expression.
ls_eq_isChecked() and ls_eq_isUnchecked() return an
expression evaluating whether a checkbox is checked (or not).
ls_eq_brace() simply embraces expr, an expression
(i.e. it prepends { and appends }).
ls_eq_quote() simply embraces expr, an expression
(i.e. it prepends ' and appends ').
A character vector.
ls_eq_build("questionCode", "==", "Y");ls_eq_build("questionCode", "==", "Y");
if equationsThis function takes a series of conditions and corresponding values, and builds an equation consisting of nested if statements.
ls_eq_nestIfs(conditions, values, elseExpr, quoteValues = FALSE)ls_eq_nestIfs(conditions, values, elseExpr, quoteValues = FALSE)
conditions |
The conditions - in the right order, i.e. in the produced expression if nested if statements, the first condition in this list will be checked first, then the second, etc. |
values |
The values corresponding to each condition (in the same order!). |
elseExpr |
The value to return if there are no matches. |
quoteValues |
Whether to use double quotes to quote the values. |
A character value.
### Relatively simple example with four levels of nesting ls_eq_nestIfs(c("age.NAOK > 80", "age.NAOK > 65", "age.NAOK > 40", "age.NAOK > 20"), c("Respectable", "Roughly retired", "Roughly middle-aged", "Quite young"), "Very young", quoteValue=TRUE);### Relatively simple example with four levels of nesting ls_eq_nestIfs(c("age.NAOK > 80", "age.NAOK > 65", "age.NAOK > 40", "age.NAOK > 20"), c("Respectable", "Roughly retired", "Roughly middle-aged", "Quite young"), "Very young", quoteValue=TRUE);
This function can be used to import files exported by LimeSurvey.
ls_import_data( sid = NULL, path = NULL, datafile = NULL, dataPath = NULL, datafileRegEx = NULL, scriptfile = NULL, setVarNames = TRUE, setLabels = TRUE, convertToCharacter = FALSE, convertToFactor = FALSE, categoricalQuestions = NULL, massConvertToNumeric = TRUE, dataHasVarNames = TRUE, dataEncoding = "UTF-8-BOM", scriptEncoding = NULL, sticky = limonaid::opts$get("sticky"), silent = limonaid::opts$get("silent") )ls_import_data( sid = NULL, path = NULL, datafile = NULL, dataPath = NULL, datafileRegEx = NULL, scriptfile = NULL, setVarNames = TRUE, setLabels = TRUE, convertToCharacter = FALSE, convertToFactor = FALSE, categoricalQuestions = NULL, massConvertToNumeric = TRUE, dataHasVarNames = TRUE, dataEncoding = "UTF-8-BOM", scriptEncoding = NULL, sticky = limonaid::opts$get("sticky"), silent = limonaid::opts$get("silent") )
sid, path
|
The easiest way to load data is to not rename the datafile
and script file downloaded from LimeSurvey (so that both contain the Survey
Identifier, the |
datafile |
The path and filename of the file containing the data (comma separated values). |
dataPath, datafileRegEx
|
Path containing datafiles: this can be used to read multiple datafiles, if the data is split between those. This is useful when downloading the entire datafile isn't possible because of server restrictions, for example when the processing time for the script in LimeSurvey that generates the datafiles is limited. In that case, the data can be downloaded in portions, and specifying a path here enables reading all datafiles in one go. Use the regular expression to indicate which files in the path should be read. |
scriptfile |
The path and filename of the file containing the R script to import the data. |
setVarNames, setLabels, convertToCharacter, convertToFactor
|
Whether to set variable names or labels, or convert to character or factor, using the code isolated using the specified regular expression. |
categoricalQuestions |
Which variables (specified using LimeSurvey variable names) are considered categorical questions; for these, the script to convert the variables to factors, as extracted from the LimeSurvey import file, is applied. |
massConvertToNumeric |
Whether to convert all variables to numeric
using |
dataHasVarNames |
Whether the variable names are included as header (first line) in the comma separated values file (data file). |
dataEncoding, scriptEncoding
|
The encoding of the files; can be used
to override the setting in the |
sticky |
Whether to make labels sticky (requires the |
silent |
Whether to be silent or verbose ('chatty'). |
This function was intended to make importing data from LimeSurvey a bit easier. The default settings used by LimeSurvey are not always convenient, and this function provides a bit more control.
The dataframe.
## Not run: ### Of course, you need valid LimeSurvey files. This is an example of ### what you'd do if you have them, assuming you specified that path ### containing the data in 'dataPath', the name of the datafile in ### 'dataFileName', the name of the script file in 'dataLoadScriptName', ### and that you only want variables 'informedConsent', 'gender', 'hasJob', ### 'currentEducation', 'prevEducation', and 'country' to be converted to ### factors. dat <- limonaid::ls_import_data( datafile = file.path(dataPath, dataFileName), scriptfile = file.path(dataPath, dataLoadScriptName), categoricalQuestions = c('informedConsent', 'gender', 'hasJob', 'currentEducation', 'prevEducation', 'country') ); ## End(Not run)## Not run: ### Of course, you need valid LimeSurvey files. This is an example of ### what you'd do if you have them, assuming you specified that path ### containing the data in 'dataPath', the name of the datafile in ### 'dataFileName', the name of the script file in 'dataLoadScriptName', ### and that you only want variables 'informedConsent', 'gender', 'hasJob', ### 'currentEducation', 'prevEducation', and 'country' to be converted to ### factors. dat <- limonaid::ls_import_data( datafile = file.path(dataPath, dataFileName), scriptfile = file.path(dataPath, dataLoadScriptName), categoricalQuestions = c('informedConsent', 'gender', 'hasJob', 'currentEducation', 'prevEducation', 'country') ); ## End(Not run)
This function extracts specific code bits from the LimeSurvey data
import R script, which can then be applied to imported data using
ls_apply_script_bits(), for example to update variable names, set
labels, etc.
ls_parse_data_import_script( scriptfile = NULL, scriptEncoding = limonaid::opts$get("encoding"), silent = limonaid::opts$get("silent") )ls_parse_data_import_script( scriptfile = NULL, scriptEncoding = limonaid::opts$get("encoding"), silent = limonaid::opts$get("silent") )
scriptfile |
The path and filename of the script file. |
scriptEncoding |
The encoding of the script file; can be used
to override the setting in the |
silent |
Whether to be silent or verbose ('chatty'). |
A list with four components.
This function is meant to quickly parse the variable labels set by LimeSurvey. It works particularly well with dual anchor array questions, where the left and right anchors as well as the subquestions are extracted automatically.
ls_process_labels( data, varnameRegExPairs = NULL, lengthToWrap = 50, lengthToWrapAnchors = 20, labelExtractionRegExPair = limonaid::opts$get("labelExtractionRegExPair"), leftAnchorRegExPairs = limonaid::opts$get("leftAnchorRegExPairs"), rightAnchorRegExPairs = limonaid::opts$get("rightAnchorRegExPairs") )ls_process_labels( data, varnameRegExPairs = NULL, lengthToWrap = 50, lengthToWrapAnchors = 20, labelExtractionRegExPair = limonaid::opts$get("labelExtractionRegExPair"), leftAnchorRegExPairs = limonaid::opts$get("leftAnchorRegExPairs"), rightAnchorRegExPairs = limonaid::opts$get("rightAnchorRegExPairs") )
data |
The dataframe as produced by |
varnameRegExPairs |
Pairs of regular expressions to replace in the variable names. This is useful when some pattern can be applied to the variable names to, for example, add underscores te denote different parts of the variable name. This has to be a list of character vectors that each have length 2. |
lengthToWrap |
At how many characters to wrap the subquestions. |
lengthToWrapAnchors |
At how many characters to wrap the anchors. |
labelExtractionRegExPair |
The regular expression pair used to extract the labels. |
leftAnchorRegExPairs |
The regular expression pairs to use to extract the left anchors. |
rightAnchorRegExPairs |
The regular expression pairs to use to extract the right anchors. |
This function processes LimeSurvey variable labels and applies regular expressions to automatically extract subquestions and left and right anchors.
A dataframe.
### No examples provided yet; this would require data to be included, ### and that's not available yet.### No examples provided yet; this would require data to be included, ### and that's not available yet.
Read a LimeSurvey Tab-Separated Values file
ls_read_tsv(file, encoding = limonaid::opts$get("encoding"))ls_read_tsv(file, encoding = limonaid::opts$get("encoding"))
file |
The filename to read. |
encoding |
The encoding to use when reading the file. |
A dataframe.
### Get location of one of the example files exampleFile <- system.file( "extdata", "export-of-survey-with-one-question-as-tsv.txt", package = "limonaid" ); ### Import file lsrv <- limonaid::ls_read_tsv(exampleFile);### Get location of one of the example files exampleFile <- system.file( "extdata", "export-of-survey-with-one-question-as-tsv.txt", package = "limonaid" ); ### Import file lsrv <- limonaid::ls_read_tsv(exampleFile);
This function takes a dataframe with LimeSurvey (LS) variable codes
and values, and builds a nested set of LimeSurvey Equation Manager (LSEM)
if/then/else equations where the variable code in each row (in the
varCodeCol) is compared to the corresponding value (i.e. the value in
the same row in the valueCol column) using the operator specified in that
row in the operatorCol column (or the == operator, if no operator is
specified). In the case of a match, the value in the corresponding
recodeToCol column is returned. If there is no match, the comparison
on the next row is evaluated, all the way down. If nothing matches, the
elseExpr is returned.
ls_recodeTable_to_equations( data, varCodeCol = limonaid::opts$get("recTab2Eq_varCodeCol"), valueCol = limonaid::opts$get("recTab2Eq_valueCol"), recodeToCol = limonaid::opts$get("recTab2Eq_recodeToCol"), operatorCol = limonaid::opts$get("recTab2Eq_operatorCol"), elseExpr = limonaid::opts$get("eq_elseExpr"), naok = TRUE )ls_recodeTable_to_equations( data, varCodeCol = limonaid::opts$get("recTab2Eq_varCodeCol"), valueCol = limonaid::opts$get("recTab2Eq_valueCol"), recodeToCol = limonaid::opts$get("recTab2Eq_recodeToCol"), operatorCol = limonaid::opts$get("recTab2Eq_operatorCol"), elseExpr = limonaid::opts$get("eq_elseExpr"), naok = TRUE )
data |
The dataframe. |
varCodeCol |
The name or index of the column with the variable code. |
valueCol |
The name or index of the column with the values to compare the value of the variable code to. |
recodeToCol |
The name or index of the column with the value to return in the case of a match. |
operatorCol |
The name or index of the column with the operator used to build each logical expression. |
elseExpr |
The value to return if there are no matches. |
naok |
Whether to append " |
A character value.
### Provide later### Provide later
Get all group rows from a LimeSurvey survey dataframe
ls_tsv_get_group_rows(data)ls_tsv_get_group_rows(data)
data |
The LimeSurvey survey dataframe. |
A dataframe with the rows.
### Add### Add
Display rows from a LimeSurvey dataframe that meet a criterion
ls_tsv_get_rows(data, ...)ls_tsv_get_rows(data, ...)
data |
The datafram. |
... |
For now, one column/value pair (the criterion). |
The rows, passed through ls_tsv_rows().
### Add later### Add later
Display one or more rows from a LimeSurvey dataframe, omitting empty columns
ls_tsv_rows(dfRows)ls_tsv_rows(dfRows)
dfRows |
A dataframe with the selected rows. |
The rows, with empty columns omitted.
### Add later.### Add later.
Write a data frame to a LimeSurvey Tab Separated Values file
ls_write_lsg( data, file, encoding = limonaid::opts$get("encoding"), preventOverwriting = limonaid::opts$get("preventOverwriting"), silent = limonaid::opts$get("silent") )ls_write_lsg( data, file, encoding = limonaid::opts$get("encoding"), preventOverwriting = limonaid::opts$get("preventOverwriting"), silent = limonaid::opts$get("silent") )
data |
The dataframe to write. |
file |
The file to write to. |
encoding |
The encoding to write to. |
preventOverwriting |
Whether to prevent overwriting, should the target file exist, already. |
silent |
Whether to be silent or chatty. |
The dataframe, adapted for writing, invisibly.
### Add example once something is available.### Add example once something is available.
Write a data frame to a LimeSurvey Tab Separated Values file
ls_write_tsv( data, file, encoding = limonaid::opts$get("encoding"), preventOverwriting = limonaid::opts$get("preventOverwriting"), silent = limonaid::opts$get("silent") )ls_write_tsv( data, file, encoding = limonaid::opts$get("encoding"), preventOverwriting = limonaid::opts$get("preventOverwriting"), silent = limonaid::opts$get("silent") )
data |
The dataframe to write. |
file |
The file to write to. |
encoding |
The encoding to write to. |
preventOverwriting |
Whether to prevent overwriting, should the target file exist, already. |
silent |
Whether to be silent or chatty. |
The dataframe, adapted for writing, invisibly.
### Add example once something is available.### Add example once something is available.
This is used when exporting surveys to LimeSurvey's TSV format.
lsdf_for_language( language, groups, exportGroupIdMapping, exportQuestionIdMapping, backupLanguage, silent = limonaid::opts$get("silent") )lsdf_for_language( language, groups, exportGroupIdMapping, exportQuestionIdMapping, backupLanguage, silent = limonaid::opts$get("silent") )
language |
The language for which to produce the data frame. |
groups |
The groups object in the Survey object. |
exportGroupIdMapping, exportQuestionIdMapping
|
Used to map Survey object identifier onto the identifier model used in the LimeSurvey TSV. |
backupLanguage |
The language to get content from if not available in the primary language |
silent |
Whether to be silent or chatty. |
Invisibly, the Survey object.
This function was adapted by Gjalt-Jorn Peters from a function originally written by Andrew Heiss.
mail_registered_participant(iSurveyID, tid)mail_registered_participant(iSurveyID, tid)
iSurveyID |
... |
tid |
... |
## Not run: limonaid::mail_registered_participant(iSurveyID = 123456, tid = 2) ## End(Not run)## Not run: limonaid::mail_registered_participant(iSurveyID = 123456, tid = 2) ## End(Not run)
This function makes it easy to convert many dataframe columns to numeric.
massConvertToNumeric( dat, byFactorLabel = FALSE, ignoreCharacter = TRUE, stringsAsFactors = FALSE )massConvertToNumeric( dat, byFactorLabel = FALSE, ignoreCharacter = TRUE, stringsAsFactors = FALSE )
dat |
The dataframe with the columns. |
byFactorLabel |
When converting factors, whether to do this
by their label value ( |
ignoreCharacter |
Whether to convert ( |
stringsAsFactors |
In the returned dataframe, whether to return string (character) vectors as factors or not. |
A data.frame.
### Create a dataset a <- data.frame(var1 = factor(1:4), var2 = as.character(5:6), stringsAsFactors=FALSE); ### Ignores var2 b <- massConvertToNumeric(a); ### Converts var2 c <- massConvertToNumeric(a, ignoreCharacter = FALSE);### Create a dataset a <- data.frame(var1 = factor(1:4), var2 = as.character(5:6), stringsAsFactors=FALSE); ### Ignores var2 b <- massConvertToNumeric(a); ### Converts var2 c <- massConvertToNumeric(a, ignoreCharacter = FALSE);
The limonaid::opts object contains three functions to set, get, and reset
options used by the escalc package. Use limonaid::opts$set to set options,
limonaid::opts$get to get options, or limonaid::opts$reset to reset specific or
all options to their default values.
optsopts
An object of class list of length 4.
It is normally not necessary to get or set limonaid options.
The following arguments can be passed:
For limonaid::opts$set, the dots can be used to specify the options
to set, in the format option = value, for example,
silent = FALSE. For
limonaid::opts$reset, a list of options to be reset can be passed.
For limonaid::opts$set, the name of the option to set.
For limonaid::opts$get, the default value to return if the
option has not been manually specified.
The following options can be set:
Whether to be chatty or silent.
The encoding to use when writing files.
The name of the column with the missing values.
### Get the default silent setting limonaid::opts$get('silent'); ### Set it to FALSE limonaid::opts$set(silent = FALSE); ### Check that it worked limonaid::opts$get('silent'); ### Reset this option to its default value limonaid::opts$reset('silent'); ### Check that the reset worked, too limonaid::opts$get('silent');### Get the default silent setting limonaid::opts$get('silent'); ### Set it to FALSE limonaid::opts$set(silent = FALSE); ### Check that it worked limonaid::opts$get('silent'); ### Reset this option to its default value limonaid::opts$reset('silent'); ### Check that the reset worked, too limonaid::opts$get('silent');
This function makes it easy to parse the dropouts from a LimeSurvey questionnaire.
processLimeSurveyDropouts(lastpage, pagenames = NULL, relevantPagenames = NULL)processLimeSurveyDropouts(lastpage, pagenames = NULL, relevantPagenames = NULL)
lastpage |
A vector with the 'lastpage' variable as LimeSurvey stores it (an integer denoting the last page a participant visited, in other words, where they dropped out). |
pagenames |
Optional: names for each page. |
relevantPagenames |
Optional: the names of those pages that should be included. |
This will be described more in detail in a forthcoming publications.
A list with information about the dropout, including plots.
limonaid::processLimeSurveyDropouts(c(1,2,1,1,2,3,2,2,3,2,1));limonaid::processLimeSurveyDropouts(c(1,2,1,1,2,3,2,2,3,2,1));
R6 Class representing a LimeSurvey question
R6 Class representing a LimeSurvey question
A question has at least a code and a primary language.
The human-readable question types are (with some additional variants also being valid, in any case the literal labels used at https://www.limesurvey.org/manual/Question_object_types#Current_question_types):
"array dual scale"
"5 point choice"
"5 point array"
"10 point array"
"yes/no/uncertain array"
"date"
"increase/same/decrease array"
"array" (this is the "array (flexible labels)" type)
"gender"
"array by column"
"language switch"
"multiple numerical input",
"radio" (this is the "list" type)
"checkboxes" (this is the "multiple choice" type)
"numerical input",
"list with comment"
"multiple choice with comments"
"multiple short text"
"ranking"
"short text"
"long text"
"huge text"
"text display"
"yes/no"
"multiple texts array",
"multiple dropdown array"
"file"
"dropdown"
"equation".
codeThe code of the question.
idThe identifier of the question (a unique number in a survey).
gidThe identifier of the group to which this question belongs.
sidThe identifier of the survey to which this question belongs.
typeThe question type.
lsTypeThe question type in LimeSurvey's format.
questionTextsThe question text(s) in all languages.
helpTextsThe question help text(s) in all languages.
relevanceThe relevance.
validationThe question's validation.
languageThe primary language of the question.
additional_languagesAny additional languages for the title and description elements.
answerOptionsThe answer options in the question.
subquestionsThe subquestions in the question.
parent_qidThe question identifier of the parent question (or 0).
mandatoryWhether the question is mandatory (Y or N).
otherWhether the question has an 'other' option (Y or N).
otherReplaceTextsIf the question has an 'other' option, its label if the default label should be overwritten (multilingual).
defaultThe default value.
same_defaultNot entirely sure what this does.
array_filterThe question code of the array filter question to apply.
question_orderThe question order (starts at 0)
cssclassThe CSS class(es) to apply to this question.
hide_tipWhether to hide the tip (Y or N).
otherOptionsAny additional options, stored as a named list
by assigning as.list(...).
has_subquestionsWhether the question has subquestions.
has_answerOptionsWhether the question has answer options
new()
Create a new question object. Most of this text comes directly from the TSV manual page at https://www.limesurvey.org/manual/Tab_Separated_Value_survey_structure, so please see that page for more details.
Question$new( code, type = NULL, lsType = NULL, id = NULL, gid = NULL, sid = NULL, questionTexts = "", helpTexts = "", relevance = 1, validation = "", mandatory = "N", parent_qid = 0, other = "N", otherReplaceTexts = "", default = "", same_default = "0", array_filter = "", cssclass = "", hide_tip = "", language = "en", additional_languages = "", new_id_fun = NULL, question_order = 0, ... )
codeThe question code.
typeThe human-readable question type (see details).
lsTypeThe type as LimeSurvey type ("1"; "5"; "A" to "Y",
except "J", "V" and "W"; "!"; ":"; ";"; "*"; or "|" –see
https://www.limesurvey.org/manual/Question_object_types#Current_question_types).
idThe identifier of the question (in a survey).
gidThe identifier of the group to which this question belongs.
sidThe identifier of the survey to which this question belongs.
questionTextsThe question text(s).
helpTextsThe help text(s).
relevanceThe question's relevance equation.
validationThe question's validation.
mandatoryWhether the question is mandatory (Y or N);.
parent_qidThe question identifier of the parent question (or 0).
otherWhether the question has an 'other' option (Y or N).
otherReplaceTextsIf the question has an 'other' option, its label if the default label should be overwritten (multilingual).
defaultThe default value.
same_defaultY for true, in which case any default value set
for the primary language applies to other languages.
array_filterThe question code of the array filter question to apply.
cssclassThe CSS class(es) to apply to this question.
hide_tipWhether to hide the tip (Y or N).
languageThe question's primary language.
additional_languagesAny additional languages
new_id_funA function to set identifiers (for XML exports, which mirrors MySQL tables and so needs identifiers). By default, new question objects receive this function from the group containing them; and groups receive it from the survey containing them. This ensures that identifiers are always unique in a survey (despite question objects not being able to 'see' anything in the group containing them, and group objects not being able to 'see' anything in the survey containing them; because they 'received' this function from the parent object, and it 'bubbles down' through groups to the questions, those functions still get and set a private identifier property in the 'top-most' object).
question_orderThe question order (starts at 0)
...Any additional options, stored as a named list in the
otherOptions property by assigning as.list(...).
A new Question object.
add_answer_option()
Add an answer option to a question. Most of this text comes directly from the TSV manual page at https://www.limesurvey.org/manual/Tab_Separated_Value_survey_structure, so please see that page for more details.
Question$add_answer_option( code, optionTexts, type.scale = 0, relevance = "", assessment.value = 0, sort.order = NULL )
codeThe answer option code.
optionTextsThe answer option text(s).
type.scale0 or 1 (e.g. for dual-scale; 'scale_id').
relevanceThe answer option's relevance equation.
assessment.valueIf using assessment, this is the assessment value for the answer ('assessment_value').
sort.orderThe sort order (to manually specify); starts at 0. If left empty, new options are added at the bottom.
Invisibly, the question object.
add_subquestion()
Add a subquestion to a question. Most of this text comes directly from the TSV manual page at https://www.limesurvey.org/manual/Tab_Separated_Value_survey_structure, so please see that page for more details.
Question$add_subquestion( code, subquestionTexts, relevance = "", helpTexts = NULL, type.scale = 0, validation = "", mandatory = "", default = "", same_default = "", subquestion.order = NULL )
codeThe subquestions code.
subquestionTextsThe subquestion text(s).
relevanceWhen to show this subquestion.
helpTextsAs far as I know not yet implemented in LimeSurvey; but the TSV help page says "(Future) to support subquestion-level help".
type.scale0 or 1, depending upon question type (e.g. array
text will have two scales)0 or 1, depending upon question type (e.g.
array text will have two scales)."
validationAs far as I know not yet implemented in LimeSurvey; but the TSV help page says "(Future) to support subquestion-level regular expression validation (e.g. for address parts)"
mandatoryAs far as I know not yet implemented in LimeSurvey; but the TSV help page says "(Future) to support subquestion-level mandatory (e.g. make only a few subquestions mandatory)"
defaultIf set, then this is the default value for the subquestion (inserted into defaultvalues table).
same_defaultIf set, then the default for the primary language is used for all other languages.
subquestion.orderThe subquestion order (to manually specify); starts at 0. If left empty, new options are added at the bottom.
Invisibly, the question object.
xmlExport_row_question()
Export the question in XML format (for lss, lsg, or lsq files).
Question$xmlExport_row_question(silent = limonaid::opts$get("silent"))silentWhether to be silent or chatty.
The produced XML
xmlExport_row_subquestions()
Export the question in XML format (for lss, lsg, or lsq files).
Question$xmlExport_row_subquestions(
returnRows = FALSE,
silent = limonaid::opts$get("silent")
)returnRowsWhether to return a list with each row as element,
or a rows node (as xml2 object) containing each row as nodes
silentWhether to be silent or chatty.
The produced XML
xmlExport_row_question_l10ns()
Export the question's question_l10ns info in a list of XML nodes.
Question$xmlExport_row_question_l10ns(
id_fun = private$new_id(),
silent = limonaid::opts$get("silent")
)id_funThe function to use to produce unique identifiers
silentWhether to be silent or chatty.
The produced list of XML nodes
xmlExport_row_answers()
Export the answer options in XML format (for lss, lsg, or lsq files).
Question$xmlExport_row_answers(
returnRows = FALSE,
silent = limonaid::opts$get("silent")
)returnRowsWhether to return a list with each row as element,
or a rows node (as xml2 object) containing each row as nodes
silentWhether to be silent or chatty.
The produced XML
xmlExport_row_answer_l10ns()
Export the question's answer optoin l10ns info in a list of XML nodes.
Question$xmlExport_row_answer_l10ns(
id_fun = private$new_id,
silent = limonaid::opts$get("silent")
)id_funThe function to use to produce unique identifiers
silentWhether to be silent or chatty.
The produced list of XML nodes
xmlExport_row_attributes()
Export the question's attributes in a list of XML nodes.
Question$xmlExport_row_attributes(silent = limonaid::opts$get("silent"))silentWhether to be silent or chatty.
The produced list of XML nodes
clone()
The objects of this class are cloneable with this method.
Question$clone(deep = FALSE)
deepWhether to make a deep clone.
Repeat a string a number of times
repeatStr(n = 1, str = " ")repeatStr(n = 1, str = " ")
n, str
|
Normally, respectively the frequency with which to repeat the string and the string to repeat; but the order of the inputs can be switched as well. |
A character vector of length 1.
### 10 spaces: repStr(10); ### Three euro symbols: repStr("\u20ac", 3);### 10 spaces: repStr(10); ### Three euro symbols: repStr("\u20ac", 3);
R6 Class representing a LimeSurvey survey
R6 Class representing a LimeSurvey survey
Create and work with a Survey to programmatically (or interactively) create a survey, export it to a tab separated values file, and import it to LimeSurvey.
titlesThe title of the survey in the primary language and any additional languages
descriptionsThe descriptions of the survey in the primary language and any additional languages
welcomeTextsThe welcome texts of the survey in the primary language and any additional languages
endTextsThe end texts of the survey in the primary language and any additional languages
endURLsThe end URLs of the survey in the primary language and any additional languages
endURLdescriptionsThe end URL descriptions of the survey in the primary language and any additional languages
dateformatsThe date format to use in the primary language and any additional languages; the index of the option from the dropdown in LimeSurvey (6 is the ISO standard, "YYYY-MM-DD").
numberformatsThe number format to use in
the primary language and any additional languages (for periods as
decimal marks, 0; for commas as decimal marks, 1).
sidThe unique survey identifier; if this is free when importing the survey, this will be used.
gsidThe Survey Group identifier.
adminThe name of the survey administrator
adminemailThe email address of the survey administrator
anonymizedWhether the survey uses anonymized
responses (Y or N).
faxtoThe contents of the "Fax to" field
formatHow to present the survey (Q for question by
question; G for group by group; and A for all in one).
savetimingsWhether to save timings of responses (Y or N).
templateThe name of the LimeSurvey theme to use.
languageThe primary language of the survey.
additional_languagesAny additional languages the survey uses.
datestampWhether to datestamp responses (Y or N).
usecookieWhether to use cookies to enable answer persistence.
allowregisterWhether to allow public registration (Y or N).
allowsaveWhether to allow users to save their responses and
returning later (Y or N).
autonumber_startWhere to start autonumbering
autoredirectWhether to automatically redirect users to a
URL (Y or N).
allowprevWhether to allow users to return to previous
pages (Y or N).
printanswersWhether to allow printing of answer (Y or N).
ipaddrWhether to store IP addresses (Y or N).
refurlWhether to store the referring URL (Y or N).
showsurveypolicynoticeWhether to show the data policy
notice (Y or N).
publicstatisticsWhether to have public statistics (Y or N).
publicgraphsWhether to show graphs in public
statistics (Y or N).
listpublicWhether to list the survey publicly (Y or N).
htmlemailWhether to use HTML format for token
emails (Y or N).
sendconfirmationWhether to send confirmation
emails (Y or N).
tokenanswerspersistenceWhether to use token-based
response persistence (Y or N).
assessmentsWhether to use assessments (Y or N).
usecaptchaWhether to use CAPTCHA's (Y or N).
usetokensWhether to use tokens (Y or N).
bounce_emailWhere bouncing emails should be sent.
emailresponsetoWhere detailed admin notifications emails should be sent.
emailnotificationtoWhere a notification should be sent for new responses.
tokenlengthThe token length.
showxquestionsWhether to show "There are X questions in this
survey" (Y or N).
showgroupinfoWhether to show group name and info (B for both,
?, or X to show nothing).
shownoanswerWhether to show the "No answer" option (Y or N).
showqnumcodeWhether to show answer codes or numbers (Y, N,
or X to show nothing).
bounceprocessingWhether to process bouncing emails? (Y or N).
showwelcomeWhether to show the welcome page (Y or N).
showprogressWhether to show the progress bar (Y or N).
questionindexWhether to show the question index (0 to
disable; can also be set to incremental or full (1 and 2?)).
navigationdelayThe navigation delay in seconds
nokeyboardWhether to show the on-screen keyboard (Y or N).
alloweditaftercompletionWhether to allow multiple
reponses (N) or to allow updating responses with one token (Y)?
googleanalyticsstyleThe google analytics settings; 0 for None,
other values for other settings.
googleanalyticsapikeyThe google analytics API key.
groupsThe groups in the survey.
tsvDataUsed to store the dataframe saved to a file as tab separated values.
get_group_idsA list of all group ids.
get_group_titlesA list of all group ids.
new()
Create a new survey object.
Survey$new( titles, descriptions = "", welcomeTexts = "", endTexts = "", endURLs = "", endURLdescriptions = "", dateformats = 6, numberformats = 0, sid = 1, gsid = 1, admin = "Admin Name", adminemail = "[email protected]", anonymized = "Y", faxto = "", format = "G", savetimings = "Y", template = "vanilla", language = "en", additional_languages = "", datestamp = "Y", usecookie = "N", allowregister = "N", allowsave = "N", autonumber_start = 0, autoredirect = "Y", allowprev = "N", printanswers = "N", ipaddr = "N", refurl = "N", showsurveypolicynotice = "0", publicstatistics = "N", publicgraphs = "N", listpublic = "N", htmlemail = "Y", sendconfirmation = "N", tokenanswerspersistence = "N", assessments = "N", usecaptcha = "N", usetokens = "N", bounce_email = "", emailresponseto = "", emailnotificationto = "", tokenlength = 15, showxquestions = "N", showgroupinfo = "X", shownoanswer = "N", showqnumcode = "X", bounceprocessing = "N", showwelcome = "N", showprogress = "N", questionindex = "0", navigationdelay = "0", nokeyboard = "N", alloweditaftercompletion = "N", googleanalyticsstyle = 0, googleanalyticsapikey = "", new_id_fun = NULL )
titlesThe titles of the survey in the primary language and optionally any addiitonal languages.
descriptionsThe descriptions of the survey in the primary language and any additional languages
welcomeTextsThe welcome texts of the survey in the primary language and any additional languages
endTextsThe end texts of the survey in the primary language and any additional languages
endURLsThe end URLs of the survey in the primary language and any additional languages
endURLdescriptionsThe end URL descriptions of the survey in the primary language and any additional languages
dateformatsThe date formats to use in the primary language and any additional languages; the index of the option from the dropdown in LimeSurvey (6 is the ISO standard, "YYYY-MM-DD").
numberformatsThe number formats to use in
the primary language and any additional languages (for periods as
decimal marks, 0; for commas as decimal marks, 1).
sidThe unique survey identifier; if this is free when importing the survey, this will be used.
gsidThe Survey Group identifier.
adminThe name of the survey administrator
adminemailThe email address of the survey administrator
anonymizedWhether the survey uses anonymized
responses (Y or N).
faxtoThe contents of the "Fax to" field
formatHow to present the survey (Q for question by
question; G for group by group; and A for all in one).
savetimingsWhether to save timings of responses (Y or N).
templateThe name of the LimeSurvey theme to use.
languageThe primary language of the survey.
additional_languagesAny additional languages the survey uses.
datestampWhether to datestamp responses (Y or N).
usecookieWhether to use cookies to enable answer persistence.
allowregisterWhether to allow public registration (Y or N).
allowsaveWhether to allow users to save their responses and
returning later (Y or N).
autonumber_startWhere to start autonumbering
autoredirectWhether to automatically redirect users to a
URL (Y or N).
allowprevWhether to allow users to return to previous
pages (Y or N).
printanswersWhether to allow printing of answer (Y or N).
ipaddrWhether to store IP addresses (Y or N).
refurlWhether to store the referring URL (Y or N).
showsurveypolicynoticeWhether to show the data policy
notice (Y or N).
publicstatisticsWhether to have public statistics (Y or N).
publicgraphsWhether to show graphs in public
statistics (Y or N).
listpublicWhether to list the survey publicly (Y or N).
htmlemailWhether to use HTML format for token
emails (Y or N).
sendconfirmationWhether to send confirmation
emails (Y or N).
tokenanswerspersistenceWhether to use token-based
response persistence (Y or N).
assessmentsWhether to use assessments (Y or N).
usecaptchaWhether to use CAPTCHA's (Y or N).
usetokensWhether to use tokens (Y or N).
bounce_emailWhere bouncing emails should be sent.
emailresponsetoWhere detailed admin notifications emails should be sent.
emailnotificationtoWhere a notification should be sent for new responses.
tokenlengthThe token length.
showxquestionsWhether to show "There are X questions in this
survey" (Y or N).
showgroupinfoWhether to show group name and info (Y, N,
or X to show nothing).
shownoanswerWhether to show the "No answer" option (Y or N).
showqnumcodeWhether to show answer codes or numbers (Y, N,
or X to show nothing).
bounceprocessingWhether to process bouncing emails? (Y or N).
showwelcomeWhether to show the welcome page (Y or N).
showprogressWhether to show the progress bar (Y or N).
questionindexWhether to show the question index (0 to
disable; can also be set to incremental or full (1 and 2?)).
navigationdelayThe navigation delay in seconds
nokeyboardWhether to show the on-screen keyboard (Y or N).
alloweditaftercompletionWhether to allow multiple
reponses (N) or to allow updating responses with one token (Y)?
googleanalyticsstyleThe google analytics settings; 0 for None,
other values for other settings.
googleanalyticsapikeyThe google analytics API key.
new_id_funA function to set identifiers (for XML exports, which mirrors MySQL tables and so needs identifiers). By default, new question objects receive this function from the group containing them; and groups receive it from the survey containing them. This ensures that identifiers are always unique in a survey (despite question objects not being able to 'see' anything in the group containing them, and group objects not being able to 'see' anything in the survey containing them; because they 'received' this function from the parent object, and it 'bubbles down' through groups to the questions, those functions still get and set a private identifier property in the 'top-most' object).
A new Survey object.
add_group()
Add a group to a survey object.
Survey$add_group(titles, descriptions = "", relevance = 1, random_group = "")
titlesThe group's title, either as a named character vector where each element is the group title in a different language, and every element's name is the language code; or as a single character value, in which case the survey's primary language is used.
descriptionsThe group description, either as a named character vector where each element is the group description in a different language, and every element's name is the language code; or as a single character value, in which case the survey's primary language is used.
relevanceThe group's relevance equation.
random_groupThe group's randomization group.
Invisibly, the Survey object.
add_question()
Add a question to a survey object.
Survey$add_question(groupId, code, type = NULL, lsType = NULL, ...)
groupIdThe id of the group to add the question to.
codeThe question code.
typeThe question type.
lsTypeThe question type, as LimeSurvey question type.
...Additional arguments are used to create the Question using
Question$new.
Invisibly, the Survey object.
export_to_tsv()
Export the survey as a tab separated values file (see https://manual.limesurvey.org/Tab_Separated_Value_survey_structure).
Survey$export_to_tsv(
file,
preventOverwriting = limonaid::opts$get("preventOverwriting"),
parallel = TRUE,
encoding = limonaid::opts$get("encoding"),
silent = limonaid::opts$get("silent"),
backupLanguage = self$language
)fileThe filename to which to save the file.
preventOverwritingWhether to prevent overwriting.
parallelWhether to work serially or in parallel.
encodingThe encoding to use
silentWhether to be silent or chatty.
backupLanguageThe language to get content from if not from the primary langage.
Invisibly, the Survey object.
find_group_id()
Find the numeric group identifier by group title.
Survey$find_group_id(title, titleLanguage = NULL)
titleThe survey title.
titleLanguageThe language in which to search.
Invisibly, the Survey object.
clone()
The objects of this class are cloneable with this method.
Survey$clone(deep = FALSE)
deepWhether to make a deep clone.
Returns a list of lists, where each list contains a row.
transpose_df(x)transpose_df(x)
x |
The data frame. |
A list.
limonaid::transpose_df( mtcars[1:3, 1:3] );limonaid::transpose_df( mtcars[1:3, 1:3] );
Easily parse a vector into a character value
vecTxt( vector, delimiter = ", ", useQuote = "", firstDelimiter = NULL, lastDelimiter = " & ", firstElements = 0, lastElements = 1, lastHasPrecedence = TRUE ) vecTxtQ(vector, useQuote = "'", ...)vecTxt( vector, delimiter = ", ", useQuote = "", firstDelimiter = NULL, lastDelimiter = " & ", firstElements = 0, lastElements = 1, lastHasPrecedence = TRUE ) vecTxtQ(vector, useQuote = "'", ...)
vector |
The vector to process. |
delimiter, firstDelimiter, lastDelimiter
|
The delimiters
to use for respectively the middle, first
|
useQuote |
This character string is pre- and appended to all elements;
so use this to quote all elements ( |
firstElements, lastElements
|
The number of elements for which to use the first respective last delimiters |
lastHasPrecedence |
If the vector is very short, it's possible that the
sum of firstElements and lastElements is larger than the vector length. In
that case, downwardly adjust the number of elements to separate with the
first delimiter ( |
... |
Any addition arguments to |
A character vector of length 1.
vecTxtQ(names(mtcars));vecTxtQ(names(mtcars));