read: Read tabular data from a variety of formats

View source: R/read.R

readR Documentation

Read tabular data from a variety of formats

Description

Read data and optionally clean column names, keep unique rows, and convert characters to factors

Usage

read(
  filename,
  datadir = NULL,
  make.unique = TRUE,
  character2factor = FALSE,
  clean.colnames = TRUE,
  delim.reader = c("data.table", "vroom", "duckdb", "arrow"),
  xlsx.sheet = 1,
  sep = NULL,
  quote = "\"",
  na.strings = c(""),
  output = c("data.table", "default"),
  attr = NULL,
  value = NULL,
  verbose = TRUE,
  fread_verbose = FALSE,
  timed = verbose,
  ...
)

Arguments

filename

Character: filename or full path if datadir = NULL

datadir

Character: Optional path to directory where filename is located. If not specified, filename must be the full path.

make.unique

Logical: If TRUE, keep unique rows only

character2factor

Logical: If TRUE, convert character variables to factors

clean.colnames

Logical: If TRUE, clean columns names using clean_colnames

delim.reader

Character: package to use for reading delimited data

xlsx.sheet

Integer or character: Name or number of XLSX sheet to read

sep

Single character: field separator. If delim.reader = "fread" and sep = NULL, this defaults to "auto", otherwise defaults to ","

quote

Single character: quote character

na.strings

Character vector: Strings to be interpreted as NA values. For delim.reader = "duckdb", this must be a single string.

output

Character: "default" or "data.table", If default, return the delim.reader's default data structure, otherwise convert to data.table

attr

Character: Attribute to set (Optional)

value

Character: Value to set (if attr is not NULL)

verbose

Logical: If TRUE, print messages to console

fread_verbose

Logical: Passed to data.table::fread

timed

Logical: If TRUE, time the process and print to console

...

Additional parameters to pass to data.table::fread, arrow::read_delim_arrow(), vroom::vroom(), or openxlsx::read.xlsx()

Details

read is a convenience function to read:

  • RDS files using readRDS()

  • Parquet files using arrow::read_parquet()

  • XLSX files using readxl::read_excel()

  • DTA files from Stata using haven::read_dta()

  • Delimited files using data.table:fread(), arrow:read_delim_arrow(), vroom::vroom(), duckdb::duckdb_read_csv()

  • FASTA files using seqinr::read.fasta()

Author(s)

E.D. Gennatas

Examples

## Not run: 
datadir <- "~/icloud/Data"
dat <- read("iris.csv", datadir)

## End(Not run)

egenn/rtemis documentation built on Oct. 28, 2024, 6:30 a.m.