Writing Import/Export Extensions for rio
# S3 method for default .import(file, ...)
.export(file, x, ...)
# S3 method for default .export(file, x, ...)
A character string naming a file.
Additional arguments passed to methods.
A data frame or matrix to be written into a file.
.import, an R data.frame. For
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,
.export. It is possible to write new methods like with any S3 generic (e.g.,
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:
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