如何在R中读取多个.xls文件? [英] How to read multiple .xls files in r?
本文介绍了如何在R中读取多个.xls文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的列表中有18个文件(.xls),我想一次读取它们
I have 18 files(.xls) in list and I want to read them in one go
以下是我的代码:
filenames = list.files("C:/Users/ozgur.alptekin/Downloads/elif")
df.list = lapply(文件名,函数(x)read_excel(file = x,sheetIndex = 1,as.data.frame = TRUE,header = TRUE))
它不起作用
您能告诉我我做错了什么以及应该怎么做吗?
Could you please tell me what I have done wrong and how I should do it?
推荐答案
您可以简单地尝试循环吗?
Can you simply try a loop?
filenames=list.files("C:/Users/ozgur.alptekin/Downloads/elif")
for (i in 1:length(filenames) {
assign(paste0("file_", i),
read_excel(file = filenames[i],sheetIndex = 1, as.data.frame = TRUE, header = TRUE), envir = .GlobalEnv)
}
如果可以,请答复.
这篇关于如何在R中读取多个.xls文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文