rio: A Swiss-Army Knife for Data I/O

Description References See Also Examples

Description

The aim of rio is to make data file input and output as easy as possible. export and import serve as a Swiss-army knife for painless data I/O for data from almost any file format by inferring the data structure from the file extension, natively reading web-based data sources, setting reasonable defaults for import and export, and relying on efficient data import and export packages. An additional convenience function, convert, provides a simple method for converting between file types.

Note that some of rio's functionality is provided by ‘Suggests’ dependendencies, meaning they are not installed by default. Use install_formats to make sure these packages are available for use.

References

GREA provides an RStudio add-in to import data using rio.

See Also

import, import_list, export, convert, install_formats

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# export
library("datasets")
export(mtcars, "mtcars.csv") # comma-separated values
export(mtcars, "mtcars.rds") # R serialized
export(mtcars, "mtcars.sav") # SPSS

# import
x <- import("mtcars.csv")
y <- import("mtcars.rds")
z <- import("mtcars.sav")

# convert
convert("mtcars.sav", "mtcars.dta")

# cleanup
unlink(c("mtcars.csv", "mtcars.rds", "mtcars.sav", "mtcars.dta"))

leeper/rio documentation built on Nov. 26, 2018, 12:20 p.m.