Learn R Programming

batchtools (version 0.9.0)

batchMapResults: Map Over Results to Create New Jobs

Description

This function allows you to create new computational jobs (just like batchMap based on the results of a Registry.

Usage

batchMapResults(fun, ids = NULL, ..., missing.val, more.args = list(),
  target, source = getDefaultRegistry())

Arguments

fun
[function] Function which takes the result as first (unnamed) argument.
ids
[data.frame or integer] A data.frame (or data.table) with a column named “job.id”. Alternatively, you may also pass a vector of integerish job ids. If not set, defaults to the return value of findDone.
...
[any] Arguments to vectorize over (list or vector). Passed to batchMap.
missing.val
[ANY] Value to impute if the result file is missing (if not provided and a result file is not found, an exception is raised).
more.args
[list] A list of further arguments passed to fun. Default is an empty list.
target
[Registry] Empty Registry where new jobs are created for.
source
[Registry] Registry. If not explicitly passed, uses the default registry (see setDefaultRegistry).

Value

[data.table] with ids of jobs added to target.

See Also

Other Results: loadResult, reduceResultsList, reduceResults

Examples

Run this code
# Source registry: calculate squre of some numbers
tmp = makeRegistry(file.dir = NA, make.default = FALSE)
batchMap(function(x) list(square = x^2), x = 1:10, reg = tmp)
submitJobs(reg = tmp)
waitForJobs(reg = tmp)

# Target registry: map some results of first registry to calculate the square root
target = makeRegistry(file.dir = NA, make.default = FALSE)
batchMapResults(fun = function(x, y) list(sqrt = sqrt(x$square)), ids = 4:8,
  target = target, source = tmp)
submitJobs(reg = target)
waitForJobs(reg = target)

# Map old to new ids. First, get a table with results and parameters
results = rjoin(getJobPars(reg = target), reduceResultsDataTable(reg = target))

# Parameter '..id' points to job.id in 'source'. Use an inner join to combine:
ijoin(results, reduceResultsDataTable(reg = tmp), by = c("..id" = "job.id"))

Run the code above in your browser using DataLab