Consider the following example:
t1 t2 t3 t4 t5 t6
A 4 6 7 8 5
A 3 6 8 1 4
A 2 3 5 3 1
A 3 4 3 1 3
B 3 6 8 3 4
B 3 9 3 7 3
B 5 2 3 2 1
I hope to get a dataframe which checks for differences between every pair of rows possible within a group (A and B seperately).
I have been trying to subset the dataframe based on a loop and manually calculate the differences between rows. This is leading to a lot of computation and it is hard to manage the referencing after all the differences have been calculated. I am basically ending up with several lists.
The resulting dataframe needs to contain the row differences for all possible row combinations(or permutations?) within a group.
For example, for B, without considering the first column i.e. characters, the following is the expected result:
t2 t3 t4 t5 t6
0 -3 5 -4 1
-2 4 5 1 3
-2 7 0 5 2
The sign is not very important. Only the magnitude