R readr

The readr package provides file I/O functions.


Installation

readr is commonly used through Tidyverse.


Usage

Data Format

Ingress Example

Outgress Example

Native R

read_rds("data.rds")

write_rds(df, "data.rds")

Comma-delimited

read_csv("data.csv")

write_csv(df, "data.csv")

Tab-delimited

read_tsv("data.tsv")

write_tsv(df, "data.tsv")

Any delimiter

read_delim("data.txt", delim="|")

write_delim(df, "data.txt", delim="|")

Fixed width

read_fwf("data.txt", fwf_widths(c(2,2,NA)))

N/A

These functions (aside from the native R ones) all take these arguments:


CategoryRicottone