# Calculate differences for phases

Hello,

I have an experiment where I had participants (identified individually with ID) from 4 different groups eat 6 different snacks and then rate them. There were 4 phases/repetitions.

Now I want to calculate the differences between the phases to check whether there are significant intra-individual differences.
Finally, I will want to calculate the significance with an ANOVA and also visually plot the differences. Because the ANOVA needs long format, I wanted to add this information.
I want an additional column at the back with those differences, i.e. difference from phase 2 to phase 1, from phase 3 to phase 1, and from phase 4 to phase 1. And an additional column that states what is encoded there, i.e. which phase difference value is in the column in front of it.

I know this looks ridiculous but just concerning the structure, might something like this be possible:

``````add new columns diff_ratings (and diff_phases) to table_liking
for (each line until the end, check cloumn:Phase)
if Phase=1
Rating of this line -(MINUS) Rating of this line of same ID and Snack
und write the value in the new column diff_ratings
(and write ph1-ph1 in the other new column)
if Phase=2
Rating of this line - Rating of this line of same ID and Snack from Phase 1
und write the value in the new column diff_ratings
(and write ph2-ph1 in the other new column)
if Phase=3
Rating of this line - Rating of this line of same ID and Snack from Phase 1
und write the value in the new column diff_ratings
(and write ph3-ph1 in the other new column)
if Phase=4
Rating of this line - Rating of this line of same ID and Snack from Phase 1
und write the value in the new column diff_ratings
(and write ph4-ph1 in the other new column)
``````

I am having a hard time wrapping my head around even theoretically understanding it myself, so apologies in advance for my attempt at an explanation.