Data Import and Export

Last updated: January 18, 2021

The rio package

The rio package provides a simple interface for importing and exporting data through common import() and export() functions. File type is inferred from the file name extension.

Writing CSV files

For large datasets, use fwrite() from data.table. It is much faster than readr::write_csv().

Serialization

Serialization is reading/writing data frames from a file, while maintaining metadata like column type. It is similar to using .csv as an export format, but this doesn’t maintain metadata and can be much slower.


ℹī¸ This page is part of my knowledge base for R, the popular statistical programming language. I attempt to use idiomatic practices with the tidyverse collection of packages as much as possible. If you have suggestions for ways to improve this code, please contact me or use the survey link below..