I need to combine strings in the text column for matching IDs with duplicats in the ID column. Column A through Column X will have matching data and I want to preserve that in the new dataframe.
| ID | Text | column A | Column B |
|---|---|---|---|
| 1 | apple | five | 22 |
| 1 | banana | five | 22 |
| 2 | pancake | three | 8 |
| 3 | peach | two | 5 |
| 3 | mango | two | 5 |
I tried this: aggregate(Text ~ ID, data = df, toString)
I am expecting
| ID | text | Column A | Column B |
|---|---|---|---|
| 1 | apple, banana | five | 22 |
| 2 | pancake | three | 8 |
| 3 | peach, mango | two | 5 |