写入文件
使用 write 系列函数可以将结果写入文件,以下为例,将一个默认数据集写入文件
a <- mtcars
write.csv(a, file="mtcars.csv")
# 或者写入为表格
write.table(a, file="mtcars.tsv", sep = "\t", row.names = TRUE, header = TRUE)如果写入为 csv,使用 write.csv 只需要两个参数
- 变量
- 文件名
使用 write 系列函数可以将结果写入文件,以下为例,将一个默认数据集写入文件
a <- mtcars
write.csv(a, file="mtcars.csv")
# 或者写入为表格
write.table(a, file="mtcars.tsv", sep = "\t", row.names = TRUE, header = TRUE)如果写入为 csv,使用 write.csv 只需要两个参数