A dplyr
solution:
df %>%
group_by(rater) %>%
summarise(ratings = paste0(ratings, collapse = ","))
# A tibble: 2 x 2
rater ratings
* <chr> <chr>
1 rater1 1,2,3
2 rater2 1,2,3
If you prefer not to have a ,
between the ratings, just replace ","
by " "
in the collapse
argument to paste0
.
Data:
df <- data.frame(
rater = c(rep("rater1",3), rep("rater2",3)),
ratings = c(rep(c(1,2,3), 2))
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…