Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iqis/stash
Naive on-disk caching in R
https://github.com/iqis/stash
Last synced: 8 days ago
JSON representation
Naive on-disk caching in R
- Host: GitHub
- URL: https://github.com/iqis/stash
- Owner: iqis
- License: gpl-3.0
- Created: 2019-07-31T20:04:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-25T05:33:03.000Z (over 5 years ago)
- Last Synced: 2024-08-13T07:15:06.429Z (4 months ago)
- Language: R
- Homepage:
- Size: 49.8 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - iqis/stash - Naive on-disk caching in R (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# stash[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/iqis/stash?branch=master&svg=true)](https://ci.appveyor.com/project/iqis/stash)
[![Travis build status](https://travis-ci.org/iqis/stash.svg?branch=master)](https://travis-ci.org/iqis/stash)
[![Codecov test coverage](https://codecov.io/gh/iqis/stash/branch/master/graph/badge.svg)](https://codecov.io/gh/iqis/stash?branch=master)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/stash)](https://cran.r-project.org/package=stash)Creates a cache in binary in the file system for any R object, returning a reference to the cache file. This is useful if have many R objects to deal with, an cannot fit them all at once in your memory.
## Installation
```{r eval = FALSE}
devtools::install_github("iqis/stash")
```## Example
```{r include = TRUE}
require(stash)
require(magrittr)
```Make a stash.
```{r}
mtc_stash <- stash(mtcars)
mtc_stash
```This means that mtcars is written into the above location. (It is also thus exposed that I use Windows.)
Access the stash's content with an empty `[]`.
```{r}
mtc_stash[] %>% head()
```If you need to do any subsetting, you may chain `[]` or `$` right after.
```{r}
mtc_stash[][1:5, "mpg"]
mean(mtc_stash[]$cyl)
```The object also provides access other useful information.
```{r}
mtc_stash$obj_class
mtc_stash$obj_size
mtc_stash$file_path
mtc_stash$has_stash_file()
mtc_stash$has_content()
```Currently, as the data set is stashed on to the disc, we don't have a copy in the memory. But we can load it.
```{r}
mtc_stash$has_content()
mtc_stash$load_content()
mtc_stash$has_content()
mtc_stash[]
```We can also remove the in-memory content to release memory. But we still can read from the disk as in the beginning.
```{r}
mtc_stash$remove_content()
mtc_stash$has_content()
``````{r}
mtc_stash[]
```Finally we can also remove the stash on the disk. If we do this now, we will end with no data anywhere.
```{r error = TRUE}
mtc_stash$remove_stash()
mtc_stash$has_stash_file()
mtc_stash[]
```