Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/expandTemplate.R
Take a template job (i.e., a list of template rules), or a template rule, and create a job (or rule)
from them by replacing rmake
variables in the template with their values. The rmake
variable
is a identified by the $[VARIABLE_NAME]
string anywhere in the definition of a rule.
1 | expandTemplate(template, vars)
|
template |
An instance of the S3 |
vars |
A named character vector, matrix, or data frame with variable definitions. For character vector, names are variable names, values are variable values. For matrix or data frame, colnames are variable names and column values are variable values. |
If vars
is a character vector then all variables in vars
are replaced in template
so that
the result will contain length(template)
rules. If vars
is a data frame or a character
matrix then the replacement of variables is performed row-wisely. That is, a new sequence of rules is
created from template
for each row of variables in vars
so that the result will contain
nrow(vars) * length(template)
rules.
A list of rules created from template
by replacing rmake
variables.
Michal Burda
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | tmpl <- rRule('data-$[VERSION].csv', 'process-$[TYPE].R', 'output-$[VERSION]-$[TYPE].csv')
job <- expandTemplate(tmpl, c(VERSION='small', TYPE='a'))
# is equivalent to
job <- list(rRule('data-small.csv', 'process-a.R', 'output-small-a.csv'))
job <- expandTemplate(tmpl, expand.grid(VERSION=c('small', 'big'), TYPE=c('a', 'b', 'c')))
# is equivalent to
job <- list(rRule('data-small.csv', 'process-a.R', 'output-small-a.csv'),
rRule('data-big.csv', 'process-a.R', 'output-big-a.csv'),
rRule('data-small.csv', 'process-b.R', 'output-small-b.csv'),
rRule('data-big.csv', 'process-b.R', 'output-big-b.csv'),
rRule('data-small.csv', 'process-c.R', 'output-small-c.csv'),
rRule('data-big.csv', 'process-c.R', 'output-big-c.csv'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.