[Rd] parApply vs parCapply

From: Ken Knoblauch <ken.knoblauch_at_inserm.fr>
Date: Sat, 17 Mar 2012 18:03:07 +0100


I've started to use the parallel package and it works very well speeding things up. Thank you for making this easy to do.

Should I have expected that parCapply would return a vector when parApply returns a matrix?

library(parallel)

x <- matrix(rnorm(8), nc = 2)
apply(x, 2, function(y) y)

            [,1] [,2]
[1,] -0.9649685 0.91339851
[2,] -1.4313140 0.13457671
[3,] 1.0499248 1.58967879
[4,] -1.8974411 0.03639876

cl <- makeCluster(getOption("cl.cores", detectCores())) parApply(cl, x, 2, function(y) y)

            [,1] [,2]
[1,] -0.9649685 0.91339851
[2,] -1.4313140 0.13457671
[3,] 1.0499248 1.58967879
[4,] -1.8974411 0.03639876

parCapply(cl, x, function(y) y)

[1] -0.96496852 -1.43131396 1.04992479 -1.89744113 0.91339851 0.13457671
[7] 1.58967879 0.03639876

stopCluster(cl)

> sessionInfo()
R version 2.15.0 beta (2012-03-15 r58760) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods
[8] base

Thank you.

-- 
Ken Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen L├ępine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat 17 Mar 2012 - 17:06:08 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 18 Mar 2012 - 02:00:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive