CRAN status R-win build status R-mac build status R-linux build status Codecov test coverage Covrpage Summary

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

library(ripe)

ripe

The goal of ripe is to create a more flexible way to rerun {magrittr} pipelines.

Installation

remotes::install_github('yonicd/ripe')

Goal

We want to rerun the following pipeline that contains stochastic elements in a shorter and more flexible way

f <- function(){

  stats::runif(20)%>%
    sample(10)%>%
    utils::head(5)
}

set.seed(123)

replicate(n=3,f(),simplify = FALSE)

Can't I just add replicate to the end of it?

set.seed(123)

stats::runif(20)%>%
   sample(10)%>%
   utils::head(5)%>%
   replicate(n = 3,simplify = FALSE)

That didn't do what we wanted...

This is better!

set.seed(123)

stats::runif(20)%>%
  sample(10)%>%
  utils::head(5)%>%
  ripe(replicate,n=3,simplify=FALSE)

Manipulate Pipeline Replicates

We can now manipulate the pipeline or move ripe around into different subsets of the function sequence, creating iterative replication workflows.

set.seed(123)

stats::runif(20)%>%
  #sample(10)%>%
  utils::head(5)%>%
  ripe(replicate,n=3,simplify=FALSE)

Convert Pipelines to Lazy Functions

You can also quickly convert the pipelines to a lazyeval function

f <- stats::runif(20)%>%
  sample(10)%>%
  utils::head(5)%>%
  lazy()

set.seed(123)

f()

f()


yonicd/ripe documentation built on Dec. 9, 2019, 8:57 a.m.