This will analyse each Excel and combine its sheets into a single DF. A list of dataframes will be returned by the function. After the function returns the list, the dataframes are bound together.
library(readxl)
library(tidyverse)
files <- list.files(path="C:/data/55423/originals/r_test/",
pattern="*.xlsx",
full.names=TRUE)
allsheets <- function(filename) {
sheets <- readxl::excel_sheets(filename)
x <- lapply(sheets, function(x)
transform(readxl::read_excel(filename, sheet=x), sheetname=x))
return(x)
}
df <- lapply(files, allsheets)%>% bind_rows()
I hope this helps you.