dre
dre

Reputation: 504

R: Cannot Read All Worksheets in Excel

See below readxl::readxl_example() that I am attempting to copy:

path <- readxl::readxl_example("datasets.xls")
lapply(readxl::excel_sheets(path), readxl::read_excel, path=path)

The above obviously works, and I'm essentially trying to recreate for my own work, below:

df2016<- readxl::read_excel("data_2016.xlsx")
lapply(readxl::excel_sheets(df2016), readxl::read_excel, df2016= df2016)

When I run my code, I return the below error: Error: path must be a string

Upvotes: 0

Views: 2194

Answers (1)

CIAndrews
CIAndrews

Reputation: 1053

Instead of reading the excel, provide the location in the lapply function. For example:

location <- "D:/data_2016.xlsx"
lapply(readxl::excel_sheets(location), readxl::read_excel, path=location)

Upvotes: 3

Related Questions