rRule {rmake} | R Documentation |
Rule for running R scripts
Description
This rule is for execution of R scripts in order to create various file outputs.
Usage
rRule(target, script, depends = NULL, params = list(), task = "all")
Arguments
target |
Name of output files to be created |
script |
Name of the R script to be executed |
depends |
A vector of file names that the R script depends on, or |
params |
A list of R values that become available within the |
task |
A character vector of parent task names. The mechanism of tasks allows to
group rules. Anything different from |
Details
In detail, this rule executes the following command in a separate R process:
params <- params; source(script)
That is, parameters given in the params
argument are stored into the global variable
and then the script
is sourced. That is, the re-generation of the Makefile
with any change
to params
will not cause the re-execution of the recipe unless any other script dependencies change.
Issuing make clean
from the shell causes removal of all files specified in target
parameter.
Value
Instance of S3 class rmake.rule
Author(s)
Michal Burda
See Also
rule()
, makefile()
, markdownRule()
Examples
r <- rRule(target='cleandata.csv',
script='clean.R',
depends=c('data1.csv', 'data2.csv'))
# generate the content of a makefile (as character vector)
makefile(list(r))
# generate to file
tmp <- tempdir()
makefile(list(r), file.path(tmp, "Makefile"))