read_data: Read common data formats

Description Usage Arguments Value Author(s) Examples

Description

A simple wrapper for reading data which currently supports Rdata, sav, txt, csv, csv2 and xlsx. Under the hood, it uses readxl, readr and haven.

Usage

1
2
3
4
read_data(file, ...)

## Default S3 method:
read_data(file, ..., sheet = NULL, delim = NULL)

Arguments

file

Path to a file with a supported extension.

...

Additional arguments passed to underlying functions. (Currently, read_delim and read_excel.)

sheet

Specify one or more sheets when reading excel files.

delim

The deliminator used for flat files.

Value

A data.frame. If more than one sheet is read from a xlsx file (or you are reading a Rdata file) a list is returned instead.

Author(s)

Kristian D. Olsen

Examples

1
2
3
4
5
6
## Not run: 
df <- data.frame("String" = c("A", "B"), "Int" = c(1:2L), "Percent" = c(0.5, 0.75))
write_data(df, file = "example data.xlsx")
read_data(df, file = "example data.xlsx")

## End(Not run)

itsdalmo/officeR documentation built on May 18, 2019, 7:11 a.m.