Description Usage Arguments Value See Also Examples
This works by serializing x onto the worker nodes, running the computation, and finally deserializing the result.
1 | clusterApply(cl, x, fun, ...)
|
cl |
cluster is a Spark connection as returned from
|
x |
R object that can be coerced to list |
fun |
function to evaluate |
list with fun
evaluated at each element of x
makeClosure
, lapply
,
clusterApply
,
clusterExport
, in parallel
package
1 2 3 4 5 6 7 8 9 10 11 | library(sparkapi)
sc <- start_shell(master = "local")
clusterApply(sc, 1:10, function(x) x + 2)
a <- 20
helperfunc <- function(x) sin(x)
f <- function(x) helperfunc(x) + a
# To apply f you'll need to also get it's dependencies
f <- makeClosure(f, c("a", "helperfunc"))
clusterApply(sc, 1:10, f)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.