How to import multiple excel files with multiple sheet in r

大憨熊 提交于 2019-12-01 13:02:45

You can use your function read_excel_allsheets like this:

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