I have a data frame like this:
df <- data.frame (Subject = c(1,1,1,2,2,3,3), Product = c("A","B","C","B","C","A","D")
and I would like to replace it (into a "wide" format) like this:
df_replace <- data.frame(Subject = c(1,2,3), Product = c("A;B;C","B;C","A;D"))
The new Product value should be the concatenated string of the original Product values for the given Subject.
I am experimenting with dcast ... but I have not found a way to go forward. (but I am assuming... it is simple).