read_file_excel: Read Excel Files

read_file_excelR Documentation

Read Excel Files

Description

read_file_excel() reads Excel files using read_excel().

Usage

read_file_excel(
  file,
  range = NULL,
  col_types = "text",
  na = c("", ".", "NA", "na", "Na", "N/A", "n/a", "N/a", "NULL", "null", "Null"),
  guess_max = .Machine$integer.max%/%100L,
  ...
)

Arguments

file

Path to the xls/xlsx file

range

A cell range to read from, as described in cell-specification. Includes typical Excel ranges like "B3:D87", possibly including the sheet name like "Budget!B2:G14", and more. Interpreted strictly, even if the range forces the inclusion of leading or trailing empty rows or columns. Takes precedence over skip, n_max and sheet.

col_types

Either NULL to guess all from the spreadsheet or a character vector containing one entry per column from these options: "skip", "guess", "logical", "numeric", "date", "text" or "list". If exactly one col_type is specified, it will be recycled. The content of a cell in a skipped column is never read and that column will not appear in the data frame output. A list cell loads a column as a list of length 1 vectors, which are typed using the type guessing logic from col_types = NULL, but on a cell-by-cell basis.

na

Character vector of strings to interpret as missing values. By default, readxl treats blank cells as missing data.

guess_max

Maximum number of data rows to use for guessing column types.

...

Additional arguments to pass to read_excel()

Details

By default, read_file_excel() does not attempt to guess column types and reads all columns as character. This can be changed by setting col_types = "guess". If columns are guessed, the default is to use all rows; this can be changed by setting guess_max to a different value.

Note that when reading Excel files as character, dates will be read as the Excel numeric representation in character format (i.e. the date 2020-01-01 will be read as "43831"). These dates can be parsed into Date format using std_dates() or any of the janitor package's date conversion functions (the most basic being excel_numeric_to_date()).

read_file_excel() will eventually be paired with read_file_delim() to replace the internals of read_file().

Value

A tibble


jesse-smith/coviData documentation built on Jan. 14, 2023, 11:08 a.m.