%>>% | R Documentation |
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.
lhs %>>% rhs
lhs |
A dependency file name or a call to a function that creates a |
rhs |
A target file or a call to a function that creates a |
envir |
The environment in which to evaluate the arguments of the operator. |
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')
.
A list of instances of the rmake.rule
class.
Michal Burda (%>>%
operator is derived from the code of the magrittr
package by
Stefan Milton Bache and Hadley Wickham)
rule()
, makefile()
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'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.