dplyr

joining dataframes

The dplyr package includes several different kind of joining functions which allow you to join dataframes together, when they share a common id variable.

across and summary tables

Don’t make objects that have the same name as a function and how to use across() to get summary statistics

recoding variables

Series: IDHTG

I don’t often deal with questionnaire data in R, but Ariana and I have started trying import her qualtrics data into R and to write a script to score her measures. The first step is to recode the variables to make it possible to add up scores on subscales. load packages library(tidyverse) make a little dataframe df <- data.frame("pp_no" = 1:12, "sectionA_1" = c("Strongly Agree","Agree", "Disagree","Strongly Disagree"), "sectionA_2" = c("Strongly Agree","Agree", "Disagree","Strongly Disagree"), "sectionB_1" = c("Frequently","Sometimes", "Infrequently"), "sectionB_2" = c("Frequently","Sometimes", "Infrequently")) Option 1: use mutate() and case_when() My first intuition is to use case_when(), which I have written about before.