How to convert csv to xls using R?

跟風遠走 提交于 2019-12-19 04:07:50

问题


I have a folder with few hundred CSV files. What would be the easiest way to convert these to XLS format using R?

(Yes, I know CSV is Excel-compatible but I still have good reason to convert them.)


回答1:


Use the package xlsReadWrite to export to xls:

library(xlsReadWrite)
filenames <- list.files("[path_name]", pattern="*.csv", full.names=TRUE)
for(i in 1:length(filenames)){
    a <- read.csv(filenames[i])
    write.xls(a, paste("file",i,".xls", sep=""))
}


来源:https://stackoverflow.com/questions/15068915/how-to-convert-csv-to-xls-using-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!