This is a set of functions acting as counterparts to the sequential popular apply functions in base R:
btlapply
for lapply
and btmapply
for mapply
.
Internally, jobs are created using batchMap
on the provided registry.
If no registry is provided, a temporary registry (see argument file.dir
of makeRegistry
) and batchMap
will be used.
After all jobs are terminated (see waitForJobs
), the results are collected and returned as a list.
Note that these functions are one suitable for short and fail-safe operations on batch system. If some jobs fail, you have to retrieve partial results from the registry directory yourself.
btlapply(X, fun, ..., resources = list(), n.chunks = NULL,
chunk.size = NULL, reg = makeRegistry(file.dir = NA))btmapply(fun, ..., more.args = list(), simplify = FALSE, use.names = TRUE,
resources = list(), n.chunks = NULL, chunk.size = NULL,
reg = makeRegistry(file.dir = NA))
[vector
]
Vector to apply over.
[function
]
Function to apply.
[ANY
]
Additional arguments passed to fun
(btlapply
) or vectors to map over (btmapply
).
[named list
]
Computational resources for the batch jobs. The elements of this list
(e.g. something like “walltime” or “nodes”) depend on your template file.
See notes for reserved special resource names.
Defaults can be stored in the configuration file by providing the named list default.resources
.
Settings in resources
overwrite those in default.resources
.
[integer(1)
]
Passed to chunk
before submitJobs
.
[integer(1)
]
Passed to chunk
before submitJobs
.
[Registry
]
Registry. If not explicitly passed, uses the default registry (see setDefaultRegistry
).
[list
]
Additional arguments passed to fun
.
[logical(1)
]
Simplify the results using simplify2array
?
[logical(1)
]
Use names of the input to name the output?
[list
] List with the results of the function call.
# NOT RUN {
btlapply(1:3, function(x) x^2)
btmapply(function(x, y, z) x + y + z, x = 1:3, y = 1:3, more.args = list(z = 1), simplify = TRUE)
# }
Run the code above in your browser using DataLab