hi community, am pretty new to R and have a query related to read_excel function.
i am trying to import multiple files from a folder and store them as a tibble. for this I tried defining the following.
path <- "c:/My Drive/test/files/"
files <- list.files(path, pattern = "*.xlsx", full.names = T)
the following command doesn't work
library(readxl)
raw_dump <- read_excel(files, sheet = "Sheet1", col_names = TRUE) #not working
#Error: `path` must be a string
however, the following command when used with sapply works.
library(readxl)
raw_dump <- sapply(files, read_excel, simplify = FALSE) %>% bind_rows()
how does read_excel handle multiple files? isn't files a character vector of size 6? why would the function be searching for a string?
and how does sapply manage to convey the exact thing with the bind_rows()?