Transforming Qualtrics Columns


In a research project I am doing, participants are asked to compare two texts and select which text they find easier to read. Each participant will be asked to do this ten times. There are 25 texts, from which a random subset of two texts will be presented each time.

When downloading the data from Qualtrics, it is presented as a long row per participant, showing which texts are shown and which text is the 'winner' of both. However, to perform a Bradley-Terry analysis, the data should be converted to a format in which each row represents one comparison.

In the image below, I tried to visualize this. Only in the image there are only three texts, the actual output will be with 25 texts and 10 comparisons per participant.


Could you help me with how I can easily transform my data to this format? Thanks!

I'm not sure I can exactly visualize how you'd like your data to look given the layout in your image, but it sounds like you might want to use gather() to restructure your data.

Hi @tamnot01,

Are you sure that your desired data structure is actually what you want? Reshaping data by going from wide to long is fairly simple and can be handled by the functions of the tidyr package. I would be glad to help you with this but I'm not seeing how your desired data structure links up with what you receive from Qualtrix, especially w.r.t. how you've shaded the cells.


Yes! The Bradly-Terry Model requires an ouput like that, with a column for the 'winner' (the text that is easiest to read in our case), and two columns for which texts are displayed (to account for benefits of a text being read first or second).

Because my participants are judging multiple text pairs (10 per participants), the Qualtrics output will be wide, like the first example.

Is it also possible to use the tidyr package to reach my desired format? So that (1) all the 'winner' columns will be gathered in 1 column 'winner_id'; (2) All the columns that have the value 1 will be gathered in the column ' text 1' and; (3) All the columns that have the value 2 will be gathered in the column ' text 2'?