I have some data that look like this:
head(t)
sub trialnum block.x lat.x block.y lat.y diff
1 1 10 3 1355 5 1337 18
2 1 11 3 1324 5 1470 -146
3 1 12 3 1861 5 1690 171
4 1 13 3 3501 5 1473 2028
5 1 14 3 1566 5 1402 164
6 1 15 3 1380 5 1539 -159
What I would like to do is reformat the data in R such that the values of "trialnum" (there are 20 of them) are the new columns, "sub" is the row values, and each cell has the "diff" value. For example
trialnum1 trialnum2 trialnum3...
sub
1
2
3
.
.
.
Any help would be much appreciated. Although the answer is probably simple, I've been struggling with this problem for some time.