更新时间:2023-10-15 18:07:22
write.csv
只是在底层调用 write.table
,并带有适当的参数.所以你可以通过 3 次调用 write.table
来实现你想要的.
write.csv
just calls write.table
under the hood, with appropriate arguments. So you can achieve what you want with 3 calls to write.table
.
write.table(df1, "filename.csv", col.names=TRUE, sep=",")
write.table(df2, "filename.csv", col.names=FALSE, sep=",", append=TRUE)
write.table(df3, "filename.csv", col.names=FALSE, sep=",", append=TRUE)
实际上,您可以通过使用 rbind 将数据帧组合成单个 df,然后调用 write.csv 一次来避免整个问题.
Actually, you could avoid the whole issue by combining your data frames into a single df with rbind, then calling write.csv once.
write.csv(rbind(df1, d32, df3), "filename.csv")