Usage
importLimeSurveyData(datafile = NULL, scriptfile = NULL, limeSurveyRegEx.varNames = "names\\(data\\)\\[\\d*\\] <- ", limeSurveyRegEx.toChar = "data\\[, \\d*\\] <- as.character\\(data\\[, \\d*\\]\\)", limeSurveyRegEx.varLabels = "attributes\\(data\\)\\$variable.labels\\[\\d*\\] <- \".*\"", limeSurveyRegEx.toFactor = paste0("data\\[, \\d*\\] <- factor\\(data\\[, \\d*\\], ", "levels=c\\(.*\\),labels=c\\(.*\\)\\)"), limeSurveyRegEx.varNameSanitizing = list(list(pattern = "#", replacement = "."), list(pattern = "\\$", replacement = ".")), setVarNames = TRUE, setLabels = TRUE, convertToCharacter = FALSE, convertToFactor = FALSE, categoricalQuestions = NULL, massConvertToNumeric = TRUE, dataHasVarNames = TRUE, encoding = "NULL", dataEncoding = "unknown", scriptEncoding = "ASCII")
Arguments
datafile
The path and filename of the file containing the data (comma separated values).
scriptfile
The path and filename of the file containing the R script to import the data.
limeSurveyRegEx.varNames
The regular expression used to extract the variable names from the script file. The
first regex expression (i.e. the first expression between parentheses) will be
extracted as variable name.
limeSurveyRegEx.toChar
The regular expression to detect the lines in the import script where variables
are converted to the character type.
limeSurveyRegEx.varLabels
The regular expression used to detect the lines in the import script where
variable labels are set.
limeSurveyRegEx.toFactor
The regular expression used to detect the lines in the import script where
vectors are converted to factors.
limeSurveyRegEx.varNameSanitizing
A list of regular expression patterns and their replacements to sanitize the
variable names (e.g. replace hashes/pound signs ('#') by something that is not
considered the comment symbol by R).
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.
dataHasVarNames
Whether the variable names are included as header (first line) in the comma
separated values file (data file).
encoding, dataEncoding, scriptEncoding
The encoding of the files; encoding
overrides dataEncoding
and scriptEncoding
, and so can be used to specify the same encoding
for both.