は、私はこのデータを持っていたと言う:条件に基づいて複数の行の文字列を1つの行にまとめます。
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
誰もがこれを行う方法をお勧めしますか?
'tapply()'を見てください。 'do.call(rbind、lapply(split ... ...)))の代わりに使用できます。 –
@RichScrivenありがとう、あなたの提案を編集して回答してください。 –