A Swiss-Army Knife for Data I/O

Streamlined data import and export by making assumptions that the user is probably willing to make: 'import()' and 'export()' determine the data structure from the file extension, reasonable defaults are used for data import and export (e.g., 'stringsAsFactors=FALSE'), web-based import is natively supported (including from SSL/HTTPS), compressed files can be read directly without explicit decompression, and fast import packages are used where appropriate. An additional convenience function, 'convert()', provides a simple method for converting between file types.


The aim of rio is to make data file I/O in R as easy as possible by implementing four simple functions in Swiss-army knife style:

  • import() provides a painless data import experience by automatically choosing the appropriate import/read function based on file extension (or a specified format argument)
  • import_list() imports a list of data frames from a multi-object file (Excel workbook, .Rdata files, zip directory, or HTML file)
  • export() provides the same painless file recognition for data export/write functionality
  • convert() wraps import() and export() to allow the user to easily convert between file formats (thus providing a FOSS replacement for programs like Stat/Transfer or Sledgehammer). Relatedly, Luca Braglia has created a Shiny app called rioweb that provides access to the file conversion features of rio. GREA is an RStudio add-in that provides an interactive interface for reading in data using rio.

Examples

Because rio is meant to streamline data I/O, the package is extremely easy to use. Here are some examples of reading, writing, and converting data files.

Export

Exporting data is handled with one function, export():

library("rio")
 
export(mtcars, "mtcars.csv") # comma-separated values
export(mtcars, "mtcars.rds") # R serialized
export(mtcars, "mtcars.sav") # SPSS

A particularly useful feature of rio is the ability to import from and export to compressed (e.g., zip) directories, saving users the extra step of compressing a large exported file, e.g.:

export(mtcars, "mtcars.tsv.zip")

As of rio v0.5.0, export() can also write multiple data farmes to respective sheets of an Excel workbook or an HTML file:

export(list(mtcars = mtcars, iris = iris), file = "mtcars.xlsx")

Import

Importing data is handled with one function, import():

x <- import("mtcars.csv")
y <- import("mtcars.rds")
z <- import("mtcars.sav")
 
# confirm data match
all.equal(x, y, check.attributes = FALSE)
## [1] TRUE
all.equal(x, z, check.attributes = FALSE)
## [1] TRUE

Note: Because of inconsistencies across underlying packages, the data.frame returned by import might vary slightly (in variable classes and attributes) depending on file type.

In rio v0.5.0, a new list-based import function was added. This allows users to import a list of data frames from a multi-object file (such as an Excel workbook, .Rdata file, zip directory, or HTML file):

str(import_list("mtcars.xlsx"))
## List of 2
##  $ :'data.frame':	32 obs. of  11 variables:
##   ..$ mpg : num [1:32] 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##   ..$ cyl : num [1:32] 6 6 4 6 8 6 8 4 4 6 ...
##   ..$ disp: num [1:32] 160 160 108 258 360 ...
##   ..$ hp  : num [1:32] 110 110 93 110 175 105 245 62 95 123 ...
##   ..$ drat: num [1:32] 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##   ..$ wt  : num [1:32] 2.62 2.88 2.32 3.21 3.44 ...
##   ..$ qsec: num [1:32] 16.5 17 18.6 19.4 17 ...
##   ..$ vs  : num [1:32] 0 0 1 1 0 1 0 1 1 1 ...
##   ..$ am  : num [1:32] 1 1 1 0 0 0 0 0 0 0 ...
##   ..$ gear: num [1:32] 4 4 4 3 3 3 3 4 4 4 ...
##   ..$ carb: num [1:32] 4 4 1 1 2 1 4 2 2 4 ...
##  $ :'data.frame':	150 obs. of  5 variables:
##   ..$ Sepal.Length: num [1:150] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
##   ..$ Sepal.Width : num [1:150] 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
##   ..$ Petal.Length: num [1:150] 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
##   ..$ Petal.Width : num [1:150] 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
##   ..$ Species     : chr [1:150] "setosa" "setosa" "setosa" "setosa" ...

Convert

The convert() function links import() and export() by constructing a dataframe from the imported file and immediately writing it back to disk. convert() invisibly returns the file name of the exported file, so that it can be used to programmatically access the new file.

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

It is also possible to use rio on the command-line by calling Rscript with the -e (expression) argument. For example, to convert a file from Stata (.dta) to comma-separated values (.csv), simply do the following:

Rscript -e "rio::convert('iris.dta', 'iris.csv')"

Supported file formats

rio supports a wide range of file formats. To keep the package slim, all non-essential formats are supported via "Suggests" packages, which are not installed (or loaded) by default. To ensure rio is fully functional, install these packages the first time you use rio via:

install_formats()

The full list of supported formats is below:

Format Typical Extension Import Package Export Package Installed by Default
Comma-separated data .csv data.table data.table Yes
Pipe-separated data .psv data.table data.table Yes
Tab-separated data .tsv data.table data.table Yes
SAS .sas7bdat haven haven Yes
SPSS .sav haven haven Yes
Stata .dta haven haven Yes
SAS XPORT .xpt haven haven Yes
SPSS Portable .por haven Yes
Excel .xls readxl Yes
Excel .xlsx readxl openxlsx Yes
R syntax .R base base Yes
Saved R objects .RData, .rda base base Yes
Serialized R objects .rds base base Yes
Epiinfo .rec foreign Yes
Minitab .mtp foreign Yes
Systat .syd foreign Yes
"XBASE" database files .dbf foreign foreign Yes
Weka Attribute-Relation File Format .arff foreign foreign Yes
Data Interchange Format .dif utils Yes
Fortran data no recognized extension utils Yes
Fixed-width format data .fwf utils utils Yes
gzip comma-separated data .csv.gz utils utils Yes
CSVY (CSV + YAML metadata header) .csvy csvy csvy No
Feather R/Python interchange format .feather feather feather No
Fast Storage .fst fst fst No
JSON .json jsonlite jsonlite No
Matlab .mat rmatio rmatio No
OpenDocument Spreadsheet .ods readODS readODS No
HTML Tables .html xml2 xml2 No
Shallow XML documents .xml xml2 xml2 No
YAML .yml yaml yaml No
Clipboard default is tsv clipr clipr No
Google Sheets as Comma-separated data

Additionally, any format that is not supported by rio but that has a known R implementation will produce an informative error message pointing to a package and import or export function. Unrecognized formats will yield a simple "Unrecognized file format" error.

Package Philosophy

The core advantage of rio is that it makes assumptions that the user is probably willing to make. Eight of these are important:

  1. rio uses the file extension of a file name to determine what kind of file it is. This is the same logic used by Windows OS, for example, in determining what application is associated with a given file type. By removing the need to manually match a file type (which a beginner may not recognize) to a particular import or export function, rio allows almost all common data formats to be read with the same function. And if a file extension is incorrect, users can force a particular import method by specifying the format argument. Other packages do this as well, but rio aims to be more complete and more consistent than each:
  • reader handles certain text formats and R binary files
  • io offers a set of custom formats
  • ImportExport focuses on select binary formats (Excel, SPSS, and Access files) and provides a Shiny interface.
  • SchemaOnRead iterates through a large number of possible import methods until one works successfully
  1. rio uses data.table::fread() for text-delimited files to automatically determine the file format regardless of the extension. So, a CSV that is actually tab-separated will still be correctly imported. It's also crazy fast.

  2. rio, wherever possible, does not import character strings as factors.

  3. rio supports web-based imports natively, including from SSL (HTTPS) URLs, from shortened URLs, from URLs that lack proper extensions, and from (public) Google Documents Spreadsheets.

  4. rio imports from from single-file .zip and .tar archives automatically, without the need to explicitly decompress them. Export to compressed directories is also supported.

  5. rio wraps a variety of faster, more stream-lined I/O packages than those provided by base R or the foreign package. It uses data.table for delimited formats, haven for SAS, Stata, and SPSS files, smarter and faster fixed-width file import and export routines, and readxl and openxlsx for reading and writing Excel workbooks.

  6. rio stores metadata from rich file formats (SPSS, Stata, etc.) in variable-level attributes in a consistent form regardless of file type or underlying import function. These attributes are identified as:

    • label: a description of variable
    • labels: a vector mapping numeric values to character strings those values represent
    • format: a character string describing the variable storage type in the original file

    The gather_attrs() function makes it easy to move variable-level attributes to the data frame level (and spread_attrs() reverses that gathering process). These can be useful, especially, during file conversion to more easily modify attributes that are handled differently across file formats. As an example, the following idiom can be used to trim SPSS value labels to the 32-character maximum allowed by Stata:

    dat <- gather_attrs(rio::import("data.sav"))
    attr(dat, "labels") <- lapply(attributes(dat)$labels, function(x) {
        if (!is.null(x)) {
            names(x) <- substring(names(x), 1, 32)
        }
        x
    })
    export(spread_attrs(dat), "data.dta")

    In addition, two functions (added in v0.5.5) provide easy ways to create character and factor variables from these "labels" attributes. characterize() converts a single variable or all variables in a data frame that have "labels" attributes into character vectors based on the mapping of values to value labels. factorize() does the same but returns factor variables. This can be especially helpful for converting these rich file formats into open formats (e.g., export(characterize(import("file.dta")), "file.csv").

  7. rio imports and exports files based on an internal S3 class infrastructure. This means that other packages can contain extensions to rio by registering S3 methods. These methods should take the form .import.rio_X() and .export.rio_X(), where X is the file extension of a file type. An example is provided in the rio.db package.

Package Installation

CRAN Version Downloads Travis-CI Build Status Appveyor Build status codecov.io

The package is available on CRAN and can be installed directly in R using install.packages(). You may want to run install_formats() after the first installation.

install.packages("rio")
install_formats()

The latest development version on GitHub can be installed using ghit, a lightweight alternative to devtools::install_github():

if(!require("ghit")){
    install.packages("ghit")
}
ghit::install_github("leeper/rio")

Because of how ghit handles Suggests packages, you do not need to run install_formats() when installing directly from GitHub.

News

CHANGES TO v0.5.9

  • Removed longstanding warnings from the tests of export() to fixed-width format.

CHANGES TO v0.5.8

  • Export the get_ext() function. (#169)
  • Fix a bug related to an xml2 bug (#168, h/t Jim Hester)
  • import_list() gains improved file name handling. (#164, h/t Ruaridh Williamson)
  • Removed the overwrite argument from export() method for xlsx files. Instead, existing workbooks are always overwritten unless which is specified, in which case only the specified sheet (if it exists) is overwritten. If the file exists but the which sheet does not, the data are added as a new sheet to the existing workbook. (#156)

CHANGES TO v0.5.7

  • Import of files with the ambiguous .dat extension, which are typically text-delimited files, are now passed to data.table::fread() with a message. Export to the format remains unsupported. (#98, #155)
  • Added support for export to SAS XPORT format (via haven::write_xpt()). (#157)
  • Switched default import package for SAS XPORT format to haven::read_xpt() with a haven = FALSE toggle restoring the previous default behavior using foreign::read.xpt(). (#157)

CHANGES TO v0.5.6

  • Fixed a bug in import() from compressed files wherein the which argument did not necessarily return the correct file if >=2 files in the compressed folder.
  • Tweak handling of export() to xlsx workbooks when which is specified. (#156)

CHANGES TO v0.5.5

  • Expanded test suite and increased test coverage, fixing a few tests that were failing on certain CRAN builds.

CHANGES TO v0.5.4

  • New functions characterize() and factorize() provide methods for converting "labelled" variables (e.g., from Stata or SPSS) into character or factor variables using embedded metadata. This can also be useful for exporting a metadata-rich file format into a plain text file. (#153)

CHANGES TO v0.5.3

  • Fixed a bug in writing to .zip and .tar archives related to absolute file paths.
  • Fixed some small bugs in import_list() and added tests for behavior.
  • Add .bib as known-unsupported format via bib2df::bib2df().
  • Expanded test coverage.

CHANGES TO v0.5.3

  • Fixed a bug in .import.rio_xlsx() when readxl = FALSE. (#152, h/t Danny Parsons)
  • Added a new function spread_attrs() that reverses the gather_attrs() operation.
  • Expanded test coverage.

CHANGES TO v0.5.1

  • export() now sets variables with a "labels" attribute to haven's "labelled" class.

CHANGES TO v0.5.0

  • CRAN Release.
  • Restored import of openxlsx so that writing to xlsx is supported on install. (#150)

CHANGES TO v0.4.28

  • Improved documentation of mapping between file format support and the packages used for each format. (#151, h/t Patrick Kennedy)
  • import_list() now returns a NULL entry for any failed imports, with a warning. (#149)
  • import_list() gains additional arguments rbind_fill and rbind_label to control rbind-ing behavior. (#149)

CHANGES TO v0.4.27

  • Import to and export from the clipboard now relies on clipr::read_clip() and clipr::write_clip(), respectively, thus (finally) providing Linux support. (#105, h/t Matthew Lincoln)
  • Added an rbind argument to import_list(). (#149)
  • Added a setclass argument to import_list(), ala the same in import().
  • Switched requireNamespace() calls to quietly = TRUE.

CHANGES TO v0.4.26

  • Further fixes to .csv.gz import/export. (#146, h/t Trevor Davis)

CHANGES TO v0.4.25

  • Remove unecessary urltools dependency.
  • New function import_list() returns a list of data frames from a multi-object Excel Workbook, .Rdata file, zip directory, or HTML file. (#126, #129)
  • export() can now write a list of data frames to an Excel (.xlsx) workbook. (#142, h/t Jeremy Johnson)
  • export() can now write a list of data frames to an HTML (.html) file.

CHANGES TO v0.4.24

  • Verbosity of export(format = "fwf") now depends on options("verbose").
  • Fixed various errors, warnings, and messages in fixed-width format tests.
  • Modified defaults and argument handling in internal function read_delim().
  • Fixed handling of "data.table", "tibble", and "data.frame" classes in set_class(). (#144)

CHANGES TO v0.4.23

  • Moved all non-critical format packages to Suggests, rather than Imports. (#143)
  • Added support for Matlab formats. (#78, #98)
  • Added support for fst format. (#138)

CHANGES TO v0.4.22

  • Rearranged README.
  • Bumped readxl dependency to >= 0.1.1 (#130, h/t Yongfa Chen)
  • Pass explicit excel_format arguments when using readxl functions. (#130)
  • Google Spreadsheets can now be imported using any of the allowed formats (CSV, TSV, XLSX, ODS).
  • Added support for writing to ODS files via readODS::write_ods(). (#96)

CHANGES TO v0.4.21

  • Handle HTML tables with <tbody> elements. (h/t Mohamed Elgoussi)

CHANGES TO v0.4.20

  • Fixed a big in the .import.rio_xls() and .import.rio_xlsx() where the sheet argument would return an error.

CHANGES TO v0.4.19

  • Fixed a bug in the import of delimited files when fread = FALSE. (#133, h/t Christopher Gandrud)

CHANGES TO v0.4.18

  • With new data.table release, export using fwrite() is now the default for text-based file formats.

CHANGES TO v0.4.17

  • Fixed a bug in .import.rio_xls() wherein the which argument was ignored. (h/t Mohamed Elgoussi)

CHANGES TO v0.4.16

  • Added support for importing from multi-table HTML files using the which argument. (#126)

CHANGES TO v0.4.15

  • Improved behavior of import() and export() with respect to unrecognized file types. (#124, #125, h/t Jason Becker)
  • Added explicit tests of the S3 extension mechanism for .import() and .export().
  • Attempt to recognize compressed but non-archived file formats (e.g., ".csv.gz"). (#123, h/t trevorld)

CHANGES TO v0.4.14

  • Update import and export methods to use new xml2 for XML and HTML export. (#86)

CHANGES TO v0.4.13

  • Fix failing tests related to stricter variable name handling for Stata files in development version of haven. (#113, h/t Hadley Wickham)
  • Added support for export of .sas7bdat files via haven (#116)
  • Restored support for import from SPSS portable via haven (#116)
  • Updated import methods to reflect changed formal argument names in haven. (#116)
  • Converted to roxygen2 documentation and made NEWS an explicit markdown file.

CHANGES TO v0.4.12

  • rio sets options(datatable.fread.dec.experiment=FALSE) during onLoad to address a Unix-specific locale issue.

CHANGES TO v0.4.11

  • Note unsupported NumPy i/o via RcppCNPy. (#112)
  • Fix import of European-style CSV files (sep = "," and sep2 = ";"). (#106, #107, h/t Stani Stadlmann)

CHANGES TO v0.4.10

  • Changed feather Imports to Suggests to make rio installable on older R versions. (#104)
  • Noted new RStudio add-in, GREA, that uses rio. (#109)
  • Migrated CSVY-related code to separate package (https://github.com/leeper/csvy/). (#111)

CHANGES TO v0.4.9

  • Removed unnecessary error in xlsx imports. (#103, h/t Kevin Wright)

CHANGES TO v0.4.8

  • Fixed a bug in the handling of "labelled" class variables imported from haven. (#102, h/t Pierre LaFortune)

CHANGES TO v0.4.7

  • Improved use of the sep argument for import of delimited files. (#99, h/t Danny Parsons)
  • Removed support for import of SPSS Portable (.por) files, given deprecation from haven. (#100)

CHANGES TO v0.4.5

  • Fixed other tests to remove (unimportant) warnings.
  • Fixed a failing test of file compression that was found in v0.4.3 on some platforms.

CHANGES TO v0.4.3

  • Improved, generalized, tested, and expanded documentation of which argument in import().
  • Expanded test suite and made some small fixes.

CHANGES TO v0.4.2

  • Added support to import and export to feather data serialization format. (#88, h/t Jason Becker)

CHANGES TO v0.4.1

  • Fixed behavior of gather_attrs() on a data.frame with no attributes to gather. (#94)
  • Removed unrecognized file format error for import from compressed files. (#93)

CHANGES TO v0.4.0

  • CRAN Release.

CHANGES TO v0.3.19

  • Added a gather_attrs() function that moves variable-level attributes to the data.frame level. (#80)
  • Added preliminary support for import from HTML tables (#86)

CHANGES TO v0.3.18

  • Added support for export to HTML tables. (#86)

CHANGES TO v0.3.17

  • Fixed a bug in import from remote URLs with incorrect file extensions.

CHANGES TO v0.3.16

  • Added support for import from fixed-width format files via readr::read_fwf() with a specified widths argument. This may enable faster import of these types of files and provides a base-like interface for working with readr. (#48)

CHANGES TO v0.3.15

  • Added support for import from and export to yaml. (#83)
  • Fixed a bug when reading from an uncommented CSVY yaml header that contained single-line comments. (#84, h/t Tom Aldenberg)

CHANGES TO v0.3.14

  • Diagnostic messages were cleaned up to facilitate translation. (#57)

CHANGES TO v0.3.12

  • .import() and .export() are now exported S3 generics and documentation has been added to describe how to write rio extensions for new file types. An example of this functionality is shown in the new suggested "rio.db" package.

CHANGES TO v0.3.11

  • import() now uses xml2 to read XML structures and export() uses a custom method for writing to XML, thereby negating dependency on the XML package. (#67)
  • Enhancements were made to import and export of CSVY to store attribute metadata as variable-level attributes (like imports from binary file formats).
  • import() gains a which argument that is used to select which file to return from within a compressed tar or zip archive.
  • Export to tar now tries to correct for bugs in tar() that are being fixed in base R via PR#16716.

CHANGES TO v0.3.10

  • Fixed a bug in import() (introduced in #62, 7a7480e5) that prevented import from clipboard. (h/t Kevin Wright)
  • export() returns a character string. (#82)

CHANGES TO v0.3.9

  • The use of import() for SAS, Stata, and SPSS files has been streamlined. Regardless of whether the haven = TRUE argument is used, the data.frame returned by import() should now be (nearly) identical, with all attributes stored at the variable rather than data.frame level. This is a non-backwards compatible change. (#80)

CHANGES TO v0.3.8

  • Fixed error in export to CSVY with a commented yaml header. (#81, h/t Andrew MacDonald)

CHANGES TO v0.3.7

  • export() now allows automatic file compression as tar, gzip, or zip using the file argument (e.g., export(iris, "iris.csv.zip")).

CHANGES TO v0.3.6

  • Expanded verbosity of export() for fixed-width format files and added a commented header containing column class and width information.
  • Exporting factors to fixed-width format now saves those values as integer rather than numeric.
  • Expanded test suite and separated tests into format-specific files. (#51)

CHANGES TO v0.3.5

  • Export of CSVY files now includes commenting the yaml header by default. Import of CSVY accommodates this automatically. (#74)

CHANGES TO v0.3.3

  • Export of CSVY files and metadata now supported by export(). (#73)
  • Import of CSVY files now stores dataset-level metadata in attributes of the output data.frame. (#73, h/t Tom Aldenberg)
  • When rio receives an unrecognized file format, it now issues a message. The new internal .import.default() and .export.default() then produce an error. This enables add-on packages to support additional formats through new s3 methods of the form .import.rio_EXTENSION() and .export.rio_EXTENSION().

CHANGES TO v0.3.2

  • Use S3 dispatch internally to call new (unexported) .import() and .export() methods. (#42, h/t Jason Becker)

CHANGES TO v0.3.0

  • Release to CRAN.
  • Set a default numerical precision (of 2 decimal places) for export to fixed-width format.

CHANGES TO v0.2.13

  • Import stats package for na.omit().

CHANGES TO v0.2.11

  • Added support for direct import from Google Sheets. (#60, #63, h/t Chung-hong Chan)

CHANGES TO v0.2.7

  • Refactored remote file retrieval into separate (non-exported) function used by import(). (#62)
  • Added test sutie to test file conversion.
  • Expanded test suite to include test of all export formats.

CHANGES TO v0.2.6

  • Cleaned up NAMESPACE file.

CHANGES TO v0.2.5

  • If file format for a remote file cannot be identified from the supplied URL or the final URL reported by curl::curl_fetch_memory(), the HTTP headers are checked for a filename in the Content-Disposition header. (#36)
  • Removed longurl dependency. This is no longer needed because we can identify formats using curl's url argument.
  • Fixed a bug related to importing European-style ("csv2") format files. (#44)
  • Updated CSVY import to embed variable-level metadata. (#52)
  • Use urltools::url_parse() to extract file extensions from complex URLs (e.g., those with query arguments). (#56)
  • Fixed NAMESPACE notes for base packages. (#58)

CHANGES TO v0.2.4

  • Modified behavior so that files imported using haven now store variable metadata at the data.frame level by default (unlike the default behavior in haven, which can cause problems). (#37, h/t Ista Zahn)
  • Added support for importing CSVY (http://csvy.org/) formatted files. (#52)
  • Added import dependency on data.table 1.9.5. (#39)

CHANGES TO v0.2.2

  • Uses the longurl package to expand shortened URLs so that their file type can be easily determined.

CHANGES TO v0.2.1

  • Improved support for importing from compressed directories, especially web-based compressed directories. (#38)
  • Add import dependency on curl >= 0.6 to facilitate content type parsing and format inference from URL redirects. (#36)
  • Add bit64 to Suggests to remove an import warning.

CHANGES TO v0.2

  • import always returns a data.frame, unless setclass is specified. (#22)
  • Added support for import from legacy Excel (.xls) files readxl::read_excel, making its use optional. (#19)
  • Added support for import from and export to the system clipboard on Windows and Mac OS.
  • Added support for export to simple XML documents. (#12)
  • Added support for import from simple XML documents via XML::xmlToDataFrame. (#12)
  • Added support for import from ODS spreadsheet formats. (#12, h/t Chung-hong Chan)
  • Use data.table::fread by default for reading delimited files. (#3)
  • Added support for import and export of dput and dget objects. (#10)
  • Added support for reading from compressed archives (.zip and .tar). (#7)
  • Added support for writing to fixed-width format. (#8)
  • Set stringsAsFactors = FALSE as default for reading tabular data. (#4)
  • Added support for HTTPS imports. (#1, h/t Christopher Gandrud)
  • Added support for automatic file naming in export based on object name and file format. (#5)
  • Exposed convert function.
  • Added vignette, knitr-generated README.md, and updated documentation. (#2)
  • Added some non-exported functions to simplify argument passing and streamline package API. (#6)
  • Separated import, export, convert, and utilities into separate source code files.
  • Expanded the set of supported file types/extensions, switched SPSS, SAS, and Stata formats to haven, making its use optional.

CHANGES TO v0.1.2

  • Updated documentation and fixed a bug in csv import without header.

CHANGES TO v0.1.1

  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rio")

0.5.10 by Thomas J. Leeper, 2 months ago


https://github.com/leeper/rio


Report a bug at https://github.com/leeper/rio/issues


Browse source code at https://github.com/cran/rio


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]


Documentation:   PDF Manual  


Task views: Web Technologies and Services


GPL-2 license


Imports tools, stats, utils, foreign, haven, curl, data.table, readxl, openxlsx, tibble

Suggests datasets, bit64, testthat, knitr, magrittr, clipr, csvy, feather, fst, jsonlite, readODS, readr, rmatio, xml2, yaml


Imported by boxr, car, codebook, dpmr, genogeographer, psData, userfriendlyscience.


See at CRAN