read_excel_all_sheets: Read in all the sheets at once from an excel file

View source: R/read_excel_all_sheets.R

read_excel_all_sheetsR Documentation

Read in all the sheets at once from an excel file

Description

Given an excel file with muliple sheets, the function will iterate over each sheet and save them all to a list or to individual data frames.

Usage

read_excel_all_sheets(path_to_excel_file, as_list = TRUE)

Arguments

path_to_excel_file

File path to the Excel file with multiple sheets

as_list

Logical; if TRUE Returns a list of data frames. If FALSE, multiple data frames are returned to the global environment.

Value

A list of data frames. Or a number of data frames.

References

https://stackoverflow.com/questions/12945687/read-all-worksheets-in-an-excel-workbook-into-an-r-list-with-data-frames

https://readxl.tidyverse.org/articles/articles/readxl-workflows.html#iterate-over-multiple-worksheets-in-a-workbook

Examples

library(readxl)
path <- readxl::readxl_example("datasets.xlsx")

#### As a list --------------------------------

list_of_sheets <- read_excel_all_sheets(path_to_excel_file = path,
                                        as_list = TRUE)
list_of_sheets

#### As data frames --------------------------------

read_excel_all_sheets(path_to_excel_file = path,
                      as_list = FALSE)

emilelatour/lamisc documentation built on April 9, 2024, 10:33 a.m.