Description Usage Arguments Value Author(s) Examples
Execute a MapReduce job
1 2 3 |
data |
a ddo/ddf object, or list of ddo/ddf objects |
setup |
an expression of R code (created using the R command |
map |
an R expression that is evaluated during the map stage. For each task, this expression is executed multiple times (see details). |
reduce |
a vector of R expressions with names pre, reduce, and post that is evaluated during the reduce stage. For example |
output |
a "kvConnection" object indicating where the output data should reside (see |
overwrite |
logical; should existing output location be overwritten? (also can specify |
control |
parameters specifying how the backend should handle things (most-likely parameters to |
params |
a named list of objects external to the input data that are needed in the map or reduce phases |
packages |
a vector of R package names that contain functions used in |
verbose |
logical - print messages about what is being done |
"ddo" object - to keep it simple. It is up to the user to update or cast as "ddf" if that is the desired result.
Ryan Hafen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # compute min and max Sepal Length by species for iris data
# using a random partitioning of it as input
d <- divide(iris, by = rrDiv(20))
mapExp <- expression({
lapply(map.values, function(r) {
by(r, r$Species, function(x) {
collect(
as.character(x$Species[1]),
range(x$Sepal.Length, na.rm = TRUE)
)
})
})
})
reduceExp <- expression(
pre = {
rng <- c(Inf, -Inf)
}, reduce = {
rx <- unlist(reduce.values)
rng <- c(min(rng[1], rx, na.rm = TRUE), max(rng[2], rx, na.rm = TRUE))
}, post = {
collect(reduce.key, rng)
})
res <- mrExec(d, map = mapExp, reduce = reduceExp)
as.list(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.