I currently has have 20 Excel files from the same working directory. Each excel file has 5 different tabs. I would like to import the files (in one function) and name each object according to the file name and tab name.
Here is what I have so far. This returns all 20 excel files and turns them all into objects. However, It does it for the FIRST tab only, meaning I only have 20 objects. In this case, I would like 100.
For example: Excel File Name: Apple Tab1: Sheet1 Tab2: Sheet2 Tab3: Sheet3 Tab4: Sheet4 Tab5: Sheet5
So when writing a script, I would want it to output Apple_Sheet1, Apple_Sheet2, etc. for all the excel files within the same working directory. Much appreciated!
dir_path <- "C:/"
re_file <- ".xlsx"
file.list <- list.files(pattern = "*.xlsx")
for(i in file.list) {
assign(sub(".xlsx", "", i), read_excel(i))
}