このデータフレームを持つ
df <- structure(list(date = c("2008-07-31", "2008-08-04"), id = c(1L,
1L), body = list("text 2 and here another",
c("another text here",
"and this in the same row",
"one more in the same row"
))), row.names = 1:2, class = "data.frame")
body列のリストを解除して、次のような出力を得るにはどうすればよいですか。
date id body 1 2008-07-31 1 text 2 and here another 2 2008-08-04 1 another text here and this in the same row one more in the same row
私はこれを試しました:
df$body <- as.data.frame(unlist(df$body))
あなたは使用することができますpaste
の中でsapply
。
df$body <- sapply(df$body, paste, collapse = " ")
str(df$body)
# chr [1:2] "text 2 and here another" ...
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加