How to transform this Likert data ?

I stumbled upon this data:

and it was transformed into this shape:

This is described here:

Especially I am interested in that part:

"The downloaded raw data is stored in the so-called ‘long’ data format: the response of each respondent is listed on a separate row. The questions are labelled Q1 to Q20 and the table also stores a total score, gender, age, and the time needed to complete the questionnaire. The first step in working with this data is to convert it into a format that is more convenient to use.

For example, the raw data lists gender as ‘1’ or ‘2’, which can be confusing to work with. We use the codebook published with the dataset to translate integers into the strings ‘male’ and ‘female’, which are easier for humans to understand.

After refactoring some more numeric variables, I have massaged the data table into a more suitable form by removing odd values, aggregating over respondents, and pivoting part of the table. I have also added an age category to the data by splitting the respondents in four groups of approximately equal size. This process results in the table below."

Unfortunately, the author didn't show how he achieved those steps in order to finally get that result:

So far I have tried with pivot_longer() but I have realised that it is more complicated than it looked beforehand.

Any help with that would be greatly appreciated, thank you.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.