tst <- data.frame(ID = c(123, 123, 123, 124, 124, 124),
Identifier = c("S2", "S2", "S5", "S3", "S2", "S2"),
Speed = c(15,24,11,34,13,15),
Box_loc = c(801,802,803,801,802,803),
Ord = c(86,87,90,81,82,84))
I have been attempting to flip the above data from long to wide format, however whenever i try to research it myself, the data does not look similar enough for me to be able to translate it properly. And it seems like it should be a simple solution, but maybe I am missing some critical details.
ID | Identifier(801) | Speed(801) | Ord(801) | Identifier(802) | Speed(802) | Ord(802) | Identifier(803) | Speed(803) | Ord(803) |
---|---|---|---|---|---|---|---|---|---|
123 | S2 | 15 | 86 | S2 | 24 | 87 | S5 | 11 | 90 |
124 | S3 | 34 | 81 | S2 | 13 | 82 | S2 | 15 | 84 |
I want to get my data to look like this table. The actual data has more than just 2 ID's (if that matters), and the numbers in the headers are the Box_loc. So in other words, for each Box_loc, there are IDs from 123-250 which each need their own row with these columns. My actual file has 10 columns or so, but the syntax should be about the same.