batchMapResults {BatchJobs}R Documentation

Maps a function over the results of a registry by using batchMap.

Description

Maps a function over the results of a registry by using batchMap.

Usage

batchMapResults(
  reg,
  reg2,
  fun,
  ...,
  ids,
  part = NA_character_,
  more.args = list()
)

Arguments

reg

[Registry]
Registry whose results should be mapped by fun.

reg2

[Registry]
Empty registry that should store the job for the mapping.

fun

[function(job, res, ...)]
Function to map over results of reg. Further arguments come from ... of batchMapResults and more.args.

...

[any]
Furher arguments to vectorize over (list or vector). Must all be the same length as number of results in reg.

ids

[integer]
Ids of jobs whose results should be mapped with fun. Default is all jobs.

part

[character] Only useful for multiple result files, then defines which result file part(s) should be loaded. NA means all parts are loaded, which is the default.

more.args

[list]
A list of other arguments passed to fun. Default is empty list.

Value

Vector of type integer with job ids.

Examples

reg1 = makeRegistry(id = "BatchJobsExample1", file.dir = tempfile(), seed = 123)
# square some numbers
f = function(x) x^2
batchMap(reg1, f, 1:10)

# submit jobs and wait for the jobs to finish
submitJobs(reg1)
waitForJobs(reg1)

# look at results
reduceResults(reg1, fun = function(aggr,job,res) c(aggr, res))

reg2 = makeRegistry(id = "BatchJobsExample2", file.dir = tempfile(), seed = 123)

# define function to tranform results, we simply do the inverse of the squaring
g = function(job, res) sqrt(res)
batchMapResults(reg1, reg2, fun = g)

# submit jobs and wait for the jobs to finish
submitJobs(reg2)
waitForJobs(reg2)

# check results
reduceResults(reg2, fun = function(aggr,job,res) c(aggr, res))

[Package BatchJobs version 1.9 Index]