Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jsta/externalrdata

Template for R packages that fetch, cache, and serve data from external sources
https://github.com/jsta/externalrdata

Last synced: about 1 month ago
JSON representation

Template for R packages that fetch, cache, and serve data from external sources

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```

## externalrdata

[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Travis-CI Build Status](https://travis-ci.org/jsta/externalrdata.svg?branch=master)](https://travis-ci.org/jsta/externalrdata)

This package is a template R package to fetch, cache, and serve data from external sources. All data sources are assumed to be `csv` files. The typical workflow would be to fork this package and rename the project-specific pieces including:

* `temp_get`
* _baseurl_
* _files_
* `cache_path`
* _appname_
* _appauthor_
* function prefixes (e.g. change `temp_get` to `myspecificproject_get`)

## Installation

```{r eval=FALSE}
# install devtools if not found
# install.packages(devtools)
devtools::install_github("jsta/externalrdata")
```

## Usage

```{r }
library(externalrdata)
```

### Download external data and store in file system

```{r message=FALSE, eval=FALSE}
# for demonstration purposes we will set on-the-fly compilation to FALSE
temp_get(version_id = "1", compile = FALSE)
```

### List files

```{r }
temp_ls(version_id = "1")
```

### Compile version

```{r }
# these files have metadata headers that need to be skipped
temp_compile(version_id = "1", skip = c(16, 38))
```

### List versions

```{r }
temp_versions()
```

### Load data

```{r }
dt <- temp_load(version_id = "1")
names(dt)
lapply(dt, head)
```

## Examples

### Uses this template

* https://github.com/jsta/nesRdata
* https://github.com/jsta/nsws

### Uses as similar strategy

* https://github.com/jsta/nhdR

## Contributing

Contributions welcome in the form of issues and pull requests.