grapes-greater-than-greater-than-grapes: A pipe operator for rmake rules

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This pipe operator simplifies the definition of multiple rmake rules that constitute a chain, that is, if a first rule depends on the results of a second rule, which depends on the results of a third rule and so on.

Usage

1
lhs %>>% rhs

Arguments

lhs

A dependency file name or a call to a function that creates a rmake.rule.

rhs

A target file or a call to a function that creates a rmake.rule.

Details

The format of proper usage is as follows: 'inFile' %>>% rule() %>>% 'outFile', which is equivalent to the call rule(depends='inFile', target='outFile'). rule must be a function that accepts the named parameters depends and target and creates the rmake.rule object (see rule(), rRule(), markdownRule() etc.). inFile and outFile are file names.

Multiple rules may be pipe-lined as follows: 'inFile' %>>% rRule('script1.R') %>>% 'medFile' %>>% rRule('script2.R') %>>% 'outFile', which is equivalent to a job of two rules created with: rRule(script='script1.R', depends='inFile', target='medFile') and rRule(script='script2.R', depends='medFile', target='outFile').

Value

A list of instances of the rmake.rule class.

Author(s)

Michal Burda (%>>% operator is derived from the code of the magrittr package by Stefan Milton Bache and Hadley Wickham)

See Also

rule(), makefile()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
job1 <- 'data.csv' %>>%
  rRule('preprocess.R') %>>%
  'data.rds' %>>%
  markdownRule('report.rnw') %>>%
  'report.pdf'

# is equivalent to

job2 <- list(rRule(target='data.rds', script='preprocess.R', depends='data.csv'),
             markdownRule(target='report.pdf', script='report.rnw', depends='data.rds'))

rmake documentation built on May 1, 2019, 10:37 p.m.