Formatting Qualtrics Responses

Here is a quick piece of code to create numeric response scores when data are read in as strings (e.g., “Strongly Agree, Agree, Neutral”).

library(tidyverse)
library(dplyr)
library(plyr)

df <- read.csv("path")

labels_to_values1 <- function(x){
  
  mapvalues(x, from = c("Strongly Agree", 
                        "Agree", 
                        "Slightly Agree", 
                        "Slightly Disagree", 
                        "Disagree", 
                        "Strongly Disagree"),
                        to = c(6,5,4,3,2,1))
  
}

recode_df <- df %>%
  select(column_to_modify1, column_to_modify2, column_to_modify2, etc) %>%
  apply(2, FUN = labels_to_values1) %>%
  data.frame()

Note that R will throw you warnings if all of the response options are not used, but the code will still work.

Bo\(^2\)m =)