我有一个列表var1:
var1 <- list(c("parts of a day", "time in astronomy", "star"), c("tree tall", "pine tree"), c("environmental condition", "climate"))我想把它保存在磁盘里。例如,磁盘中保存的文件必须在csv文件的每一行中具有以下内容:
"parts of a day"
"time in astronomy"
"star"
"Tree tall"
"pine tree"
"environmental condition"
"climate" 我试过了
capture.output(unlist(var1), file="a1.csv", append=FALSE)但这将创建以下格式:
[1] "parts of a day" "time in astronomy" "star" "tree tall" 5“松树”“环境状况”“气候”
如何解决这一问题?请给我一个代码片段。
谢谢。
发布于 2015-05-26 12:13:30
你可以试试
cat(paste0("'", unlist(var1), "'"), file='yourfile.txt', sep="\n")或者不使用paste,我们可以使用shQuote
cat(shQuote(unlist(var1)), file='john.txt', sep="\n")https://stackoverflow.com/questions/30456150
复制相似问题