Skip to main content
added 2 characters in body
Source Link
Edo
  • 7.9k
  • 2
  • 13
  • 21

just to provide a proper answer outside of the comment section...

  • If your target is to read many Excel files, you shouldn't use source.
  • source is dedicated to run external R code.
  • If you need to read many Excel files you can use the following code and the support of one of these libraries: readxl, openxlsx, tidyxl (with unpivotr).
filelist <- dir(folder, recursive = TRUE, full.names = TRUE, pattern = ".xlsx$|.xls$", ignore.case = TRUE) l_df <- lapply(filelist, readxl::read_excel) 

Note that we are using dir to list the full paths (full.names = TRUE) of all the files that ends with .xlsx, .xls (pattern = ".xlsx$|.xls$"), .XLSX, .XLS (ignore.case = TRUE) in the folder folder and all its subfolders (recursive = TRUE).


readxl is integrated with tidyverse. It is pretty easy to use. It is most likely what you're looking for.

Personally, I advice to use openxlsx if you need to write (rather than read) customized Excel files with many specific features.

tidyxl is the best package I've seen to read Excel files, but it may be rather complicated to use. However, it's really careful in the types preservation. With the support of unpivotr it allows you to handle complicated Excel structures. For example, when you find multiple headers and multiple left index columns.

just to provide a proper answer outside of the comment section...

  • If your target is to read many Excel files, you shouldn't use source.
  • source is dedicated to run external R code.
  • If you need to read many Excel files you can use the following code and the support of one of these libraries: readxl, openxlsx, tidyxl (with unpivotr).
filelist <- dir(folder, recursive = TRUE, full.names = TRUE, pattern = ".xlsx$|.xls$", ignore.case = TRUE) l_df <- lapply(filelist, readxl::read_excel) 

Note that we are using dir to list the full paths (full.names = TRUE) of all the files that ends with .xlsx, .xls (pattern = ".xlsx$|.xls$"), .XLSX, .XLS (ignore.case = TRUE) in the folder folder and all its subfolders recursive = TRUE.


readxl is integrated with tidyverse. It is pretty easy to use. It is most likely what you're looking for.

Personally, I advice to use openxlsx if you need to write (rather than read) customized Excel files with many specific features.

tidyxl is the best package I've seen to read Excel files, but it may be rather complicated to use. However, it's really careful in the types preservation. With the support of unpivotr it allows you to handle complicated Excel structures. For example, when you find multiple headers and multiple left index columns.

just to provide a proper answer outside of the comment section...

  • If your target is to read many Excel files, you shouldn't use source.
  • source is dedicated to run external R code.
  • If you need to read many Excel files you can use the following code and the support of one of these libraries: readxl, openxlsx, tidyxl (with unpivotr).
filelist <- dir(folder, recursive = TRUE, full.names = TRUE, pattern = ".xlsx$|.xls$", ignore.case = TRUE) l_df <- lapply(filelist, readxl::read_excel) 

Note that we are using dir to list the full paths (full.names = TRUE) of all the files that ends with .xlsx, .xls (pattern = ".xlsx$|.xls$"), .XLSX, .XLS (ignore.case = TRUE) in the folder folder and all its subfolders (recursive = TRUE).


readxl is integrated with tidyverse. It is pretty easy to use. It is most likely what you're looking for.

Personally, I advice to use openxlsx if you need to write (rather than read) customized Excel files with many specific features.

tidyxl is the best package I've seen to read Excel files, but it may be rather complicated to use. However, it's really careful in the types preservation. With the support of unpivotr it allows you to handle complicated Excel structures. For example, when you find multiple headers and multiple left index columns.

Source Link
Edo
  • 7.9k
  • 2
  • 13
  • 21

just to provide a proper answer outside of the comment section...

  • If your target is to read many Excel files, you shouldn't use source.
  • source is dedicated to run external R code.
  • If you need to read many Excel files you can use the following code and the support of one of these libraries: readxl, openxlsx, tidyxl (with unpivotr).
filelist <- dir(folder, recursive = TRUE, full.names = TRUE, pattern = ".xlsx$|.xls$", ignore.case = TRUE) l_df <- lapply(filelist, readxl::read_excel) 

Note that we are using dir to list the full paths (full.names = TRUE) of all the files that ends with .xlsx, .xls (pattern = ".xlsx$|.xls$"), .XLSX, .XLS (ignore.case = TRUE) in the folder folder and all its subfolders recursive = TRUE.


readxl is integrated with tidyverse. It is pretty easy to use. It is most likely what you're looking for.

Personally, I advice to use openxlsx if you need to write (rather than read) customized Excel files with many specific features.

tidyxl is the best package I've seen to read Excel files, but it may be rather complicated to use. However, it's really careful in the types preservation. With the support of unpivotr it allows you to handle complicated Excel structures. For example, when you find multiple headers and multiple left index columns.