简体   繁体   中英

what's the difference between clusterApply() and parApply() in R?

I'm learning Apply Operations using Clusters recently. And I'm confused about the difference between

clusterApply(cl = NULL, x, fun, ...)

and

parApply(cl = NULL, X, MARGIN, FUN, ..., chunk.size = NULL)

what's the difference in the usage of above two?

according to the R,

clusterApply calls fun on the first node with arguments x[[1]] and ..., on the second node with x[[2]] and ..., and so on, recycling nodes as needed. and parApply() is also for parallel function.

clusterApply(cl = NULL, x, fun, ...) 

parApply(cl = NULL, X, MARGIN, FUN, ..., chunk.size = NULL)

In short, parApply is the parallel version of apply while clusterApply apply a function to a list of arguments. Example:

> clusterApply(cl, c(2:4), sum, 10)
[[1]]
[1] 12

[[2]]
[1] 13

[[3]]
[1] 14

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM