rio

🐟 A Swiss-Army Knife for Data I/O

https://github.com/gesistsa/rio

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 23 committers (4.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (18.6%) to scientific vocabulary

Keywords

cran csv csvy data data-science excel io r rio sas spss stata

Keywords from Contributors

date-time data-manipulation grammar visualisation curl rmarkdown pandoc package-creation literate-programming latex
Last synced: 6 months ago · JSON representation

Repository

🐟 A Swiss-Army Knife for Data I/O

Basic Info
Statistics
  • Stars: 616
  • Watchers: 21
  • Forks: 77
  • Open Issues: 16
  • Releases: 17
Topics
cran csv csvy data data-science excel io r rio sas spss stata
Created almost 11 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog Contributing

README.Rmd

---
output: github_document
---

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


[![CRAN Version](https://www.r-pkg.org/badges/version/rio)](https://cran.r-project.org/package=rio)
![Downloads](https://cranlogs.r-pkg.org/badges/rio)
[![Codecov test coverage](https://codecov.io/gh/gesistsa/rio/graph/badge.svg)](https://app.codecov.io/gh/gesistsa/rio)


## Overview

The aim of **rio** is to make data file I/O in R as easy as possible by implementing two main 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)
 - `export()` provides the same painless file recognition for data export/write functionality

## Installation

The package is available on [CRAN](https://cran.r-project.org/package=rio) and can be installed directly in R using `install.packages()`.

```R
install.packages("rio")
```

The latest development version on GitHub can be installed using:

```R
if (!require("remotes")){
    install.packages("remotes")
}
remotes::install_github("gesistsa/rio")
```

Optional: Installation of additional formats (see below: **Supported file formats**)

```R
library(rio)
install_formats()
```

## Usage

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.

### Import

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

```{r import1}
library("rio")
import("starwars.xlsx")
```

```{r import2}
import("starwars.csv")
```

### Export

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

```{r exports}
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 archives (e.g., zip), saving users the extra step of compressing a large exported file, e.g.:

```{r export_zip}
export(mtcars, "mtcars.tsv.zip")
```

`export()` can also write multiple data frames to respective sheets of an Excel workbook or an HTML file:

```{r export_a_list}
export(list(mtcars = mtcars, iris = iris), file = "mtcars.xlsx")
```

## Supported file formats

**rio** supports a wide range of file formats. To keep the package slim, several formats are supported via "Suggests" packages, which are not installed (or loaded) by default. You can check which formats are **not** supported via:

```R
show_unsupported_formats()
```

You can install the suggested packages individually, depending your own needs. If you want to install all suggested packages:

```R
install_formats()
```

The full list of supported formats is below:

```{r, include = FALSE}
suppressPackageStartupMessages(library(data.table))
```

```{r featuretable, echo = FALSE}
rf <- data.table(rio:::rio_formats)[!input %in% c(",", ";", "|", "\\t") & type %in% c("import", "suggest", "archive"),]
short_rf <- rf[, paste(input, collapse = " / "), by = format_name]
type_rf <- unique(rf[,c("format_name", "type", "import_function", "export_function", "note")])

feature_table <- short_rf[type_rf, on = .(format_name)]

colnames(feature_table)[2] <- "signature"

setorder(feature_table, "type", "format_name")
feature_table$import_function <- stringi::stri_extract_first(feature_table$import_function, regex = "[a-zA-Z0-9\\.]+")
feature_table$import_function[is.na(feature_table$import_function)] <- ""
feature_table$export_function <- stringi::stri_extract_first(feature_table$export_function, regex = "[a-zA-Z0-9\\.]+")
feature_table$export_function[is.na(feature_table$export_function)] <- ""

feature_table$type <- ifelse(feature_table$type %in% c("suggest"), "Suggest", "Default")
feature_table <- feature_table[,c("format_name", "signature", "import_function", "export_function", "type", "note")]

colnames(feature_table) <- c("Name", "Extensions / \"format\"", "Import Package", "Export Package", "Type", "Note")

knitr::kable(feature_table)
```

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.

## Other functions

### 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.

```{r convert}
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')"
```

### *_list

`import_list()` 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):

```{r import_list}
str(m <- import_list("mtcars.xlsx"))
```

`export_list()` makes it easy to export a list of (possibly named) data frames to multiple files:

```{r export_list}
export_list(m, "%s.tsv")
c("mtcars.tsv", "iris.tsv") %in% dir()
```

```{r cleanup, echo=FALSE, results="hide"}
unlink("mtcars.csv")
unlink("mtcars.dta")
unlink("mtcars.sav")
unlink("mtcars.rds")
unlink("mtcars.xlsx")
unlink("mtcars.tsv.zip")
unlink("mtcars.tsv")
unlink("iris.tsv")
```

## Other projects

### GUIs

* [**datamods**](https://cran.r-project.org/package=datamods) provides Shiny modules for importing data via `rio`.
* [**rioweb**](https://github.com/lbraglia/rioweb) that provides access to the file conversion features of `rio`.
* [**GREA**](https://github.com/Stan125/GREA/) is an RStudio add-in that provides an interactive interface for reading in data using `rio`.

### Similar packages

* [**reader**](https://cran.r-project.org/package=reader) handles certain text formats and R binary files
* [**io**](https://cran.r-project.org/package=io) offers a set of custom formats
* [**ImportExport**](https://cran.r-project.org/package=ImportExport) focuses on select binary formats (Excel, SPSS, and Access files) and provides a Shiny interface.
* [**SchemaOnRead**](https://cran.r-project.org/package=SchemaOnRead) iterates through a large number of possible import methods until one works successfully

Owner

  • Name: Transparent Social Analytics
  • Login: gesistsa
  • Kind: organization
  • Location: Germany

Open Science Tools maintained by Transparent Social Analytics Team, GESIS

GitHub Events

Total
  • Issues event: 17
  • Watch event: 19
  • Delete event: 3
  • Issue comment event: 27
  • Push event: 10
  • Pull request review comment event: 5
  • Pull request review event: 5
  • Pull request event: 10
  • Create event: 3
Last Year
  • Issues event: 17
  • Watch event: 19
  • Delete event: 3
  • Issue comment event: 27
  • Push event: 10
  • Pull request review comment event: 5
  • Pull request review event: 5
  • Pull request event: 10
  • Create event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 618
  • Total Committers: 23
  • Avg Commits per committer: 26.87
  • Development Distribution Score (DDS): 0.421
Past Year
  • Commits: 29
  • Committers: 2
  • Avg Commits per committer: 14.5
  • Development Distribution Score (DDS): 0.31
Top Committers
Name Email Commits
Thomas J. Leeper t****r@g****m 358
chainsawriot c****y@g****m 155
Alex Bokov b****v@u****u 29
christophergandrud c****d@g****m 12
schochastics d****d@s****t 12
Hugo Gruson 1****o 9
Jason Becker j****n@j****o 9
Bill Denney b****y 8
Patrick Kennedy p****q 4
Trevor L Davis t****s@g****m 3
Jim Hester j****r@g****m 3
Ruaridh Williamson r****w 2
Ista Zahn i****n@g****m 2
Christophe Dervieux c****x@g****m 2
Andrew MacDonald a****d@g****m 2
Ryan Price r****e@s****m 1
Ege Rubak r****k@m****k 1
Hadley Wickham h****m@g****m 1
KNnut 9****t 1
Nate n****y@g****m 1
Oliver Keyes I****s 1
Ryan Price r****c@g****m 1
jrnold j****d@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 88
  • Total pull requests: 31
  • Average time to close issues: 2 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 27
  • Total pull request authors: 10
  • Average comments per issue: 2.69
  • Average comments per pull request: 1.48
  • Merged pull requests: 25
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 10
  • Pull requests: 9
  • Average time to close issues: 6 days
  • Average time to close pull requests: about 3 hours
  • Issue authors: 9
  • Pull request authors: 3
  • Average comments per issue: 1.6
  • Average comments per pull request: 1.22
  • Merged pull requests: 8
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • leeper (53)
  • chainsawriot (29)
  • jsonbecker (3)
  • christophergandrud (2)
  • barracuda156 (2)
  • billdenney (2)
  • hadley (2)
  • NickCH-K (2)
  • krose (1)
  • markdanese (1)
  • Stan125 (1)
  • ggrothendieck (1)
  • donlelek (1)
  • markriseley (1)
  • yannjay (1)
Pull Request Authors
  • chainsawriot (45)
  • jsonbecker (6)
  • christophergandrud (5)
  • izahn (3)
  • billdenney (2)
  • aammd (1)
  • Bisaloo (1)
  • jacobmmears (1)
  • jimhester (1)
  • Ironholds (1)
  • cderv (1)
  • KNnut (1)
Top Labels
Issue Labels
enhancement (35) bug (23) question (18) documentation (6) maintainability (4) postponed (4) v1.1 (3) v1.2 (2) help wanted (1) declutter (1)
Pull Request Labels
enhancement (4) bug (2)

Packages

  • Total packages: 2
  • Total downloads:
    • cran 33,585 last-month
  • Total docker downloads: 76,315
  • Total dependent packages: 57
    (may contain duplicates)
  • Total dependent repositories: 197
    (may contain duplicates)
  • Total versions: 45
  • Total maintainers: 1
cran.r-project.org: rio

A Swiss-Army Knife for Data I/O

  • Versions: 30
  • Dependent Packages: 57
  • Dependent Repositories: 197
  • Downloads: 33,585 Last month
  • Docker Downloads: 76,315
Rankings
Stargazers count: 0.6%
Forks count: 0.9%
Dependent repos count: 1.3%
Downloads: 1.5%
Dependent packages count: 1.5%
Average: 4.3%
Docker downloads count: 19.8%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/gesistsa/rio
  • Versions: 15
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.6 depends
  • R.utils * imports
  • curl >= 0.6 imports
  • data.table >= 1.11.2 imports
  • foreign * imports
  • haven >= 1.1.2 imports
  • lifecycle * imports
  • readxl >= 0.1.1 imports
  • stats * imports
  • stringi * imports
  • tibble * imports
  • tools * imports
  • utils * imports
  • writexl * imports
  • arrow >= 0.17.0 suggests
  • bit64 * suggests
  • clipr * suggests
  • datasets * suggests
  • fst * suggests
  • hexView * suggests
  • jsonlite * suggests
  • knitr * suggests
  • magrittr * suggests
  • pzfx * suggests
  • qs * suggests
  • readODS >= 1.6.4 suggests
  • readr * suggests
  • rmarkdown * suggests
  • rmatio * suggests
  • testthat * suggests
  • xml2 >= 1.2.0 suggests
  • yaml * suggests