I would like to take a data frame and collapse the rows on a column and simply create another column that is a vector of all the values.
For example I would like to transform a data frame like this:
id item
1 100
1 103
1 109
1 101
2 102
2 109
2 107
2 105
3 105
3 106
3 101
3 102
3 110
To:
id item
1 (100,103,109,101)
2 (102,109,107,105)
3 (105,106,101,102,110)
So the first column is the unique id and the second column is a vector/list of all the items that were seen for that id. Seems like this should be easy but I haven't been able to find a solution. As noted in the example the amount of items can vary per id.
Here is code to create the initial data frame I am trying to transform.
id <- c(1,1,1,1,2,2,2,2,3,3,3,3,3)
item <- c(100,103,109,101,102,109,107,105,105,106,101,102,110)
input_frame <- data.frame(cbind(id,item))