如何在r中导入包含多张工作表的多个excel文件

如何在r中导入包含多张工作表的多个excel文件,r,import,xlsx,R,Import,Xlsx,我有60个Excel文件。每个文件有8页。每个文件的图纸相同,但每个文件的列数不同 我遇到过不同的帖子,它们帮助我导入了一个带有多个工作表的excel。但我不想对60个文件重复这一点。有没有办法将所有60个文件和所有工作表一起导入 我偶然发现了这篇文章 . 但在那里,他们正在考虑相同的专栏,合并我不想要的一切。我只想进口 编辑。 注释中的功能如下: read_excel_allsheets <- function(filename) { sheets <- readxl::e

我有60个Excel文件。每个文件有8页。每个文件的图纸相同,但每个文件的列数不同

我遇到过不同的帖子,它们帮助我导入了一个带有多个工作表的excel。但我不想对60个文件重复这一点。有没有办法将所有60个文件和所有工作表一起导入

我偶然发现了这篇文章 . 但在那里,他们正在考虑相同的专栏,合并我不想要的一切。我只想进口

编辑。
注释中的功能如下:

read_excel_allsheets <- function(filename) {
    sheets <- readxl::excel_sheets(filename)
    x <- lapply(sheets, function(X) readxl::read_excel(filename, sheet = X))
    names(x) <- sheets
    x
}


mysheets <- read_excel_allsheets("ALL_1_18_2018.xlsx")

read\u excel\u allsheets您可以像这样使用函数
read\u excel\u allsheets

read_excel_allsheets <- function(filename) { 
  sheets <- readxl::excel_sheets(filename) 
  x <- lapply(sheets, function(X) readxl::read_excel(filename, sheet = X)) 
  names(x) <- sheets 
  x 
} 
files <- list.files(path = "/directory/in/question/", 
                     pattern = "*.xlsx",
                     full.names = TRUE)
out <- lapply(files, read_excel_allsheets)
names(out) <- basename(files)

read\u excel\u allsheets欢迎来到SO!您能否共享用于导入一张图纸的代码?所有工作表都在一个目录中吗?是否有命名约定?是的,所有工作表都在同一目录中。。以下是导入一张工作表read\u excel\u allsheets的代码