【发布时间】:2020-04-07 14:46:31
【问题描述】:
我想将作者的每四篇文章合并到一个广泛的数据框中,如果剩下的文章少于四篇,则将这些合并(例如,作者有 11 篇文章,我最终得到 2 篇 4 篇文章和 1 篇文章3)。
这是我的数据框的示例:
name text
bee _ so we know that right
bee said so
alma hello,
alma Good to hear back from you.
bee I've currently written an application
alma I'm happy about it
bee It was not the last.
alma Will this ever stop.
alma Yet another line.
alma so
我想改成这样:
name text
bee _ so we know that right said so I've currently written an application It was not the last.
alma hello, Good to hear back from you. I'm happy about it Will this ever stop
alma Yet another line. so
这是初始数据框:
df = structure(list(name = c("bee", "bee", "alma", "alma", "bee", "alma", "bee", "alma", "alma", "alma"), text = c( "_ so we know that right", "said so", "hello,", "Good to hear back from you.", "I've currently written an application", "I'm happy about it", "It was not the last.", "Will this ever stop.", "Yet another line.", "so")), .Names = c("name", "text"), row.names = c(NA, -10L), class = "data.frame")
【问题讨论】: