我有一个列表,其中每个元素包含如下字符串:
[[1]]
[1]
"diane" "bradbury"
[[2]]
[1] "diane" "bradbury"
[[3]]
[1] "derek" "legg"
我需要获得的是这样的单列数据框:
"diane bradbury"
"diane bradbury"
"derek legg"
你能告诉我吗?
感谢。
答案 0 :(得分:4)
只需将paste
与sapply
:
myList <- list(c("A", "B"), c("C", "D"), c("E", "F"))
myList
# [[1]]
# [1] "A" "B"
#
# [[2]]
# [1] "C" "D"
#
# [[3]]
# [1] "E" "F"
sapply(myList, paste, collapse = " ")
# [1] "A B" "C D" "E F"