【发布时间】:2017-10-15 21:22:40
【问题描述】:
假设我有这些数据:
df <- data.frame(
text = c("Treatment1: This text is","on two lines","","Treatment2:This text","has","three lines","","Treatment3: This has one")
)
df
text
1 Treatment1: This text is
2 on two lines
3
4 Treatment2:This text
5 has
6 three lines
7
8 Treatment3: This has one
我将如何解析此文本,以便所有“治疗”都在自己的行上,而下面的所有文本都在同一行上?
例如,这是所需的输出:
text
1 Treatment1: This text is on two lines
2 Treatment2: This text has three lines
3 Treatment3: This has one
谁能推荐一种方法来做到这一点?
【问题讨论】: