我的数据框如下:
name comment
Bill Bill is great
Bill Bill is bad
Bill Who is Bill?
Jane Jane is okay
Jane Jane is good
Jane Jane's the best
我想重塑我的数据框,使其看起来像这样:
name comment1 comment2 comment3
Bill Bill is great Bill is bad Who is Bill?
Jane Jane is okay Jane is good Jane's the best
我认为使用group_by函数可以完成此操作,但是我没有运气。
数据,格式为dput
。
df1 <-
structure(list(name = c("Bill", "Bill", "Bill", "Jane", "Jane",
"Jane"), comment = c("Bill is great", "Bill is bad", "Who is Bill?",
"Jane is okay", "Jane is good", "Jane's the best")), row.names = c(NA,
-6L), class = "data.frame")