knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

reuse

Codecov test coverage

The goal of reuse is to avoid re-running slow computations, particularly in pipes.

reuse::reuse() combines features of pins::pin_read() and pins::pin_write() with some differences:

Installation

You can install the development version of reuse like so:

# install.packages("devtools")
devtools::install_github("maurolepore/reuse")

Example

library(reuse)
one <- 1 %>% reuse("one")
two <- 2 %>% reuse("one")
two
two <- 2 %>% reuse("one", update = TRUE)
two
options(reuse.update = TRUE)

three <- 3 %>% reuse("one")
three
cache_dir <- rappdirs::user_cache_dir("reuse")
dir.exists(file.path(cache_dir, "one"))
library(pins)

board <- board_folder(cache_dir)
board %>% pin_meta("one")

board %>% pin_delete("one")
custom <- pins::board_folder(tempdir())
1 %>% reuse("abc", board = custom)

pins::pin_read(board = custom, "abc")
options(reuse.board = custom)
1 %>% reuse("def", board = custom)

pins::pin_exists(board = custom, "def")


maurolepore/reuse documentation built on May 1, 2022, 7:34 a.m.