[R] Snow parLapply

Florent Baty florent.baty at unibas.ch
Fri Nov 11 12:48:09 CET 2005


Dear R-user,

I am trying to use the function 'parLapply' from the 'snow' package 
which is supposed to work the same wys as 'lapply' but for a 
parallelized cluster of computers. The function I am trying to call in 
parallel is 'dudi.pca' (from the 'ade4' package) which performs 
principal component analyses. When I call this function on a list of 
dataframes with the regular lapply function it works correctly. If use 
the 'parLapply' there is an error message.

Example:
 > library("snow")
 > library(ade4)
 > a <- matrix(rnorm(2500),50)
 > b <- matrix(rnorm(10^4),10^2)
 > l1 <- list(a=a,b=b)
 > mycluster <- makeCluster(2,type="MPI")
Loading required package: Rmpi

        Rmpi version: 0.4-9
        Rmpi is an interface (wrapper) to MPI APIs
        with interactive R slave functionalities.
        See `library (help=Rmpi)' for details.
        2 slaves are spawned successfully. 0 failed.
 > lapply(list(a=as.data.frame(a),b=as.data.frame(b)),dudi.pca,scannf=F)
$a
Duality diagramm
class: pca dudi
$call: FUN(df = X[[1]], scannf = ..1)
..

$b
Duality diagramm
class: pca dudi
$call: FUN(df = X[[2]], scannf = ..1)

..

 > 
parLapply(mycluster,list(a=as.data.frame(a),b=as.data.frame(b)),dudi.pca,scannf=F)
[1] "Error in FUN(X[[1]], ...) : couldn't find function \"as.dudi\"\n"
[2] "Error in FUN(X[[1]], ...) : couldn't find function \"as.dudi\"\n"


On the other hand, if I call 'parLapply' with the function 'princomp' 
(which also performs PCA) everything works fine.

Example:

 > parLapply(mycluster,list(a=as.data.frame(a),b=as.data.frame(b)),princomp)
$a
Call:
princomp(x = X[[1]])
..

$b
Call:
princomp(x = X[[1]])
..

Does anybody knows why 'parLapply' does not work correctly with some 
functions?

Thanks a lot for your help,
 
Florent

-- 
--------------------------------------------------
		Dr Florent BATY
Pulmonary Gene Research, Universitätsspital Basel
   Petersgraben 4, CH-4031 Basel, Switzerland
 tel: +41 61 265 57 27 - fax: +41 61 265 45 87




More information about the R-help mailing list