Chapter 10 Reshaping

In chapter 10 we will actually reshape the AQ data from a wide format to a long format and then calculate total AQ scores from that newly created dataset.Remember there are solutions at the end of the chapter if you get stuck.

10.1 Goals

  • Read in the data and create three objects

  • use pivot_longer to take data from a wide format to a long format

  • isolate one participant and look at their data

  • Use inner_join

  • calculate AQ scores with summarise() and sum()

  • make a histogram of the scores using ggplot

10.2 Tasks

Task 1: Read in data

Complete 10.2. Read in your data and create three objects: responses, scoring, and qformats

Task 2: Using pivot_longer

Complete 10.3. Be sure to compare rlong and responses to make sure you understand what pivot_longer does. Complete 10.4 to isolate one participant and see a small portion of your new dataframe.

Task 3: Construct dataframe

Awesome, you converted the data to a long format, now we need to combine it with data from the other csv files so we can calculate total AQ scores. Complete 10.5 and 10.6 to do this.

Task 4: Calculate AQ score

Complete 10.7 and 10.8 to calculate the AQ scores for a lone participant and then all participants.

Task 5: Histogram

Complete 10.10 to make a histogram of your data.