Using R, I wish to combine rows (max of 2) per a common identifier from within the same dataset.
My dataset has an ID, Date and Text field.
df1 <- data.frame(ID = c("1", "1", "2", "3", "3"),
Date = c("2017-02-12", "2017-03-12", "2017-02-14", "2016-02-12", "2014-02-12"),
Text = c("Pie", "Cake", "Pie", "IceCream", "Chocolate"))
I want to combine rows based on the identifier without aggregating, for an end result that would double my column count.
Resulting in:
ID|Date.a | Text.a | Date.b |Text.b
1 |2017-02-12 | Pie | 2017-03-12 | Cake
2 |2017-02-14 | Pie | |
3 |2017-02-14 | IceCream| 2017-02-12 |Chocolate
Any help, much appreciated.