Skip to content

Commit

Permalink
updates for CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Sep 25, 2016
1 parent aa5c0fc commit abbb838
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.DS_Store
.Rhistory
.Rproj.user
revdep/*
2 changes: 1 addition & 1 deletion R/export.R
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export <- function(x, file, format, ...) {
compress <- NA_character_
}
if (fmt %in% c("gz", "gzip")) {
fmt <- file_ext(file_path_sans_ext(file, compress = FALSE))
fmt <- file_ext(file_path_sans_ext(file, compression = FALSE))
file <- gzfile(file, "w")
on.exit(close(file))
}
Expand Down
2 changes: 1 addition & 1 deletion R/export_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export_delim <- function(file, x, fwrite = FALSE, sep = "\t", row.names = FALSE,
#' @importFrom haven write_sas
#' @export
.export.rio_sas7bdat <- function(file, x, ...) {
write_sas(b7dat = x, path = file, ...)
write_sas(data = x, path = file, ...)
}

#' @importFrom foreign write.dbf
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ if(!require("ghit")){
ghit::install_github("leeper/rio")
```

[![CRAN Version](http://www.r-pkg.org/badges/version/rio)](http://cran.r-project.org/package=rio)
[![CRAN Version](http://www.r-pkg.org/badges/version/rio)](https://cran.r-project.org/package=rio)
![Downloads](http://cranlogs.r-pkg.org/badges/rio)
[![Travis-CI Build Status](https://travis-ci.org/leeper/rio.png?branch=master)](https://travis-ci.org/leeper/rio)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/40ua5l06jw0gjyjb?svg=true)](https://ci.appveyor.com/project/leeper/rio)
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# rio: A Swiss-Army Knife for Data I/O #
# rio: A Swiss-Army Knife for Data I/O

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

- `export()` and `import()` provide a painless data I/O experience by automatically choosing the appropriate data read or write function based on file extension
- `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](https://www.stattransfer.com/) or [Sledgehammer](https://www.mtna.us/#/products/sledgehammer)). [Luca Braglia](https://lbraglia.github.io/) has created a Shiny app called [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.

## Supported file formats ##
## Supported file formats

**rio** supports a variety of different file formats for import and export.

Expand Down Expand Up @@ -44,11 +44,11 @@ The aim of **rio** is to make data file I/O in R as easy as possible by implemen

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.

## Examples ##
## 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 ###
### Export

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

Expand All @@ -61,7 +61,7 @@ export(mtcars, "mtcars.rds") # R serialized
export(mtcars, "mtcars.sav") # SPSS
```

### Import ###
### Import

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

Expand Down Expand Up @@ -89,7 +89,7 @@ all.equal(x, z, check.attributes = FALSE)

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.

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

Expand All @@ -106,31 +106,32 @@ Rscript -e "rio::convert('iris.dta', 'iris.csv')"



## Package Philosophy ##
## 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 taking away 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. Other packages do this as well, but rio aims to be more complete and more consistent than each:
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 taking away 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. Other packages do this as well, but **rio** aims to be more complete and more consistent than each:

- [**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

2. **rio** uses 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.
2. **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.

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

4. **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.
4. **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. The `gather_attrs()` function makes it easy to move variable-level attributes to the data frame level.

5. **rio** supports web-based imports from SSL (HTTPS) URLs, from shortened URLs, and from URLs that lack proper extensions.
5. **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.

6. **rio** imports from from single-file .zip and .tar archives automatically, without the need to explicitly decompress them.
6. **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.

7. **rio** imports and exports files based on an internal S3 class infrastructure. This means that other packages can contain extensions to **rio** by importing `.import()` and/or `.export()` and then writing internal 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](https://github.com/leeper/rio.db).
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](https://github.com/leeper/rio.db).

8. **rio** wraps a variety of faster, more stream-lined I/O packages than those provided by base R or the **foreign** package. It uses [**haven**](https://cran.r-project.org/package=haven) for reading and writing SAS, Stata, and SPSS files, [the `fread` function from **data.table**](https://cran.r-project.org/package=data.table) for delimited formats, smarter and faster fixed-width file import and export routines, and [**readxl**](https://cran.r-project.org/package=readxl) for reading from Excel workbooks.

## Package Installation ##
## Package Installation

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

Expand All @@ -147,7 +148,7 @@ if(!require("ghit")){
ghit::install_github("leeper/rio")
```

[![CRAN Version](http://www.r-pkg.org/badges/version/rio)](http://cran.r-project.org/package=rio)
[![CRAN Version](http://www.r-pkg.org/badges/version/rio)](https://cran.r-project.org/package=rio)
![Downloads](http://cranlogs.r-pkg.org/badges/rio)
[![Travis-CI Build Status](https://travis-ci.org/leeper/rio.png?branch=master)](https://travis-ci.org/leeper/rio)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/40ua5l06jw0gjyjb?svg=true)](https://ci.appveyor.com/project/leeper/rio)
Expand Down
4 changes: 0 additions & 4 deletions revdep/check.R

This file was deleted.

Binary file removed revdep/checks.rds
Binary file not shown.
2 changes: 1 addition & 1 deletion vignettes/rio.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Import, Export, and Convert Data Files #

The idea behind **rio** is to simplify the process of importing data into R and exporting data from R. This process is, probably unnecessarily, extremely complex for beginning R users. Indeed, R supplies [an entire manual](http://cran.r-project.org/doc/manuals/r-release/R-data.html) describing the process of data import/export. And, despite all of that text, most of the packages described are (to varying degrees) out-of-date. Faster, simpler, packages with fewer dependencies have been created for many of the file types described in that document. **rio** aims to unify data I/O (importing and exporting) into two simple functions: `import` and `export` so that beginners (and experienced R users) never have to think twice (or even once) about the best way to read and write R data.
The idea behind **rio** is to simplify the process of importing data into R and exporting data from R. This process is, probably unnecessarily, extremely complex for beginning R users. Indeed, R supplies [an entire manual](https://cran.r-project.org/doc/manuals/r-release/R-data.html) describing the process of data import/export. And, despite all of that text, most of the packages described are (to varying degrees) out-of-date. Faster, simpler, packages with fewer dependencies have been created for many of the file types described in that document. **rio** aims to unify data I/O (importing and exporting) into two simple functions: `import` and `export` so that beginners (and experienced R users) never have to think twice (or even once) about the best way to read and write R data.

The core advantage of **rio** is that it makes assumptions that the user is probably willing to make. Specifically, **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 taking away 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.

Expand Down

0 comments on commit abbb838

Please sign in to comment.