R combine duplicate rows by appending columns [duplicate]
问题 This question already has answers here : Duplicated rows: select rows based on criteria and store duplicated values (2 answers) Closed 3 months ago . I have a large data set with text comments and their ratings on different variables, like so: df <- data.frame( comment = c("commentA","commentB","commentB","commentA","commentA","commentC" sentiment=c(1,2,1,4,1,2), tone=c(1,5,3,2,6,1) ) Every comment is present between one and 3 times, since multiple people are asked to rate the same comment