I have a data frame df
like:
year location
1 A
2 B
3 C
------------------
1 X
5 A
10 F
------------------
3 F
5 x
2 y
I would like to reshape it to
year_1 location_1 year_2 location_2 year_3 location_3
1 A 2 B 3 F
3 C 1 X 5 X
5 A 10 F 2 Y
I can do a hack, and concatenate the first two columns, and do
d <- matrix(df, nrow = 70, byrow = FALSE)
But again later I have to split the concatenated stuff, is there a neat way of doing this?