I have a folder with numerous xlsx files that all need to be formatted in the exact same way. I want to read them into R and store them as lists that can be referenced using the xlsx file name so that I can feed it through my formatting code. This is the code that I found that labels them based on the iteration value in the for loop.
library("xlsx")
library("gdata")
library("rJava")
setwd("C:/Users/Owner/Desktop/FolderDatabase")
getwd()
files = list.files(pattern = "\\.xlsx")
#View(files)
dfList <- list()
for (i in seq_along(files)){
dfList[[paste0("excel",i)]] <- read.xlsx(files[i], sheetIndex = 1)
}
# Calling the xlsx lists that were created from the directory
dfList$excel1
dfList$excel2
dfList$excel3
dfList$excel4
If the xlsx file is named myname1.xlsx, I would like the list to be named myname1.