set_question_labels: Set variable label on exported LS result data

View source: R/setQuestionLabels.R

set_question_labelsR Documentation

Set variable label on exported LS result data

Description

LimeSurvey offers the option to export survey result data as an R data frame. Column names are question codes while variable values are response codes. This function assigns the question or sub-question texts in the selected language to each variable (column). The question text is available as attribute "label" for each column. Useful in conjunction with sjlabelled::get_label() or ggplot which can automatically retrieve variable labels for graphics and/or frequency tables.

Usage

set_question_labels(data, labels, plang)

Arguments

data

Data frame of LimeSurvey R result data set.

labels

Data frame extracted from LimeSurvey *.lss xml file. See extract_question_labels

plang

char language code. One of the available language codes from the survey

Details

Speical case conserns question and sub-question texts. For example a question might inquire how respondents rate their job satisfaction along several dimensions. In such a question, the overarching question could be:

"Q1. To what extent do you agree or disagree with the following statements about your job?"

Respondents can then indicate their agreement via likert scale answer options on the sub-questions such as:

"Q1-S1. My job offers good prospects for career advancement" "Q1-S2. I generally get on well with my work colleagues" "Q1-S3. I might lose my job in the next 6 months" etc.

The individual responses to each sub-question are then stored in the corresponding columns of the result data frame. In case a column holds a sub-question, the "label" stores the sub-question text, e.g. "My job offers good prospects for career advancement", etc. This makes sense to take advantage of the plotting likert scales with the correct sub-question label attached for each item. In case of sub-questions, the corresponding parent question text (e.g. "Q1. To what extent do you agree ...") is stored with a distinct attribute "parent_label". It can be retrieved with get_lsParentlabel.

Value

data frame with attached text label for each variable (question or sub-question).

See Also

extract_question_labels


jmueller17/LimeRLabel documentation built on May 2, 2023, 7:13 p.m.