I like to use plyr
for this:
library(plyr)
ddply(df, .(Animal), summarize, Food = paste(Food, collapse = ', '))
Note that the code is untested because your example is not reproducible. However, an example using mtcars
shows that it works:
ddply(mtcars, .(gear), summarize, carb = paste(carb, collapse = ', '))
gear carb
1 3 1, 2, 1, 4, 3, 3, 3, 4, 4, 4, 1, 2, 2, 4, 2
2 4 4, 4, 1, 2, 2, 4, 4, 1, 2, 1, 1, 2
3 5 2, 2, 4, 6, 8