Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

extensions

rio Extensions


Description

Writing Import/Export Extensions for rio

Usage

.import(file, ...)

## Default S3 method:
.import(file, ...)

.export(file, x, ...)

## Default S3 method:
.export(file, x, ...)

Arguments

file

A character string naming a file.

...

Additional arguments passed to methods.

x

A data frame or matrix to be written into a file.

Details

rio implements format-specific S3 methods for each type of file that can be imported from or exported to. This happens via internal S3 generics, .import and .export. It is possible to write new methods like with any S3 generic (e.g., print).

As an example, .import.rio_csv imports from a comma-separated values file. If you want to produce a method for a new filetype with extension “myfile”, you simply have to create a function called .import.rio_myfile that implements a format-specific importing routine and returns a data.frame. rio will automatically recognize new S3 methods, so that you can then import your file using: import("file.myfile").

As general guidance, if an import method creates many attributes, these attributes should be stored — to the extent possible — in variable-level attributes fields. These can be “gathered” to the data.frame level by the user via gather_attrs.

Value

For .import, an R data.frame. For .export, file, invisibly.

See Also


rio

A Swiss-Army Knife for Data I/O

v0.5.26
GPL-2
Authors
Jason Becker [ctb], Chung-hong Chan [aut], Geoffrey CH Chan [ctb], Thomas J. Leeper [aut, cre] (<https://orcid.org/0000-0003-4097-6326>), Christopher Gandrud [ctb], Andrew MacDonald [ctb], Ista Zahn [ctb], Stanislaus Stadlmann [ctb], Ruaridh Williamson [ctb], Patrick Kennedy [ctb], Ryan Price [ctb], Trevor L Davis [ctb], Nathan Day [ctb], Bill Denney [ctb] (<https://orcid.org/0000-0002-5759-428X>), Alex Bokov [ctb] (<https://orcid.org/0000-0002-0511-9815>)
Initial release
2021-02-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.