I'm looking to edit a column in my dataset so that I can make a collection of features one row instead of many. I've considered pivot_wider and dcast but they aren't quite what I'm looking to do.
I start with something like this reprex:
df <- data.frame(a = c(2,2,2,3,3,4,5,5,5,5),
b = c("sunshine","lollipops","rainbows","clouds","rain","dinner","headphones","pen","pencil","desk"))
Something like this is my goal.
df <- data.frame(a = c(2,3,4,5),
b = c("sunshine, lollipops, rainbows","clouds, rain","dinner","headphones, pen, pencil, desk"))
I appreciate any suggestions that you may have.