I would like to adapt the answer below, taken from this question.
# Example data
write.xlsx(mtcars, "mt cars.xlsx")
write.xlsx(mtcars, "mt car s.xlsx")
temp = list.files(pattern="*.xlsx")
make_names <- function(x) {
gsub("\\.", "_", make.names(gsub("*.xlsx$", "", x)))
}
names(temp) <- make_names(temp)
list2env(lapply(temp, read.xlsx), envir = .GlobalEnv)
#> <environment: R_GlobalEnv>
ls()
#> [1] "make_names" "mt_car_s" "mt_cars" "temp"
Let's assume that one of the Excel files has a second sheet (I tried to create a replicatable, but could not figure out how to write a second sheet with write.xlsx
).
The code to load all Excel sheets from one Excel-file can be found here, (thanks to akrun). However in my case I am trying to upload a folder instead of a file.
How can I combine this code to do both of these things?
Is there an option to look for more sheets?