Skip to contents

This function reads specified sheets from an Excel file and returns them as a list of data frames. It provides options to skip rows, force date columns to be of Date type, and drop unnamed columns.

Usage

load_sheets_as_list(
  file_path,
  sheets,
  skip = 0,
  force_date = TRUE,
  drop_unnamed = TRUE,
  col_types = rep(NULL, length(sheets))
)

Arguments

file_path

A character string specifying the path to the Excel file.

sheets

A character vector specifying the names of the sheets to be read.

skip

An integer specifying the number of rows to skip at the beginning of each sheet. Default is 0.

force_date

A logical indicating whether to attempt to convert date columns to Date type. Default is TRUE.

drop_unnamed

A logical indicating whether to drop unnamed columns (columns with no header). Default is TRUE.

col_types

A list the same length as sheets, containing either NULL or a character vector of read_excel classes.

Value

A list of data frames, each corresponding to a sheet in the Excel file.

Examples

if (FALSE) { # \dontrun{
sheets_data <- load_sheets_as_list("path/to/file.xlsx", c("Sheet1", "Sheet2"), skip = 1)
} # }