I am not sure how to tackle this. I tried brainstorming idea using dplyr, transposing, etc , but cannot think of a solution. I thought I'd ask the community for help.
DF <- data.frame(ID = c(1, 1, 2, 2, 3, 3),
Time = c(0, 1, 0, 1, 0, 1),
X = c(1, 2, 3, 4, 5, 6),
Y = c(7, 8, 9, 10, 11, 12))
I have listed a sample dataset above. So, trying if there is a possibility in grouping by both Time. For instance, it would be from this:
ID Time X Y
1 0 1 7
1 1 2 8
2 0 3 9
2 1 4 10
3 0 5 11
3 1 6 12
to
ID Time_0.X Time_0.Y Time_1.X Time_1.Y
1 1 7 2 8
2 3 9 4 10
3 5 11 6 12
Please let me know if anything comes in mind. Thanks!