Reputation: 703
I want to read and load an Excel file into my environment, I'm just getting a list.
path <- "data/data.xlsx"
path %>%
excel_sheets() %>%
set_names() %>%
map(read_excel, path = path)
Upvotes: 0
Views: 363
Reputation: 408
You could try: For this example i made a xlsx with 3 sheets.
library(readxl)
# Get the sheets count
sheets <- excel_sheets("some.xlsx")
for (i in 1 : length(sheets)) {
shts <- paste("x", i, sep = ".")
# Read every single sheet and assign to variable x1, x2, x3 etc...
assign(shts, read_excel("c:/Temporal/TEST.xlsx", sheet=sheets[i]))
}
Result:
I hope this helps!
Upvotes: 2