[R] parallel computation in plyr 1.7

abhagwat bhagwataditya at gmail.com
Thu Jan 12 18:54:40 CET 2012


The code below shows that
(1) the way to activate the parallel backend indeed is to use 'registerDoMC'
(2) the function d_ply does NOT accept the argument parallel, while the
function ddply does. Perhaps it is interesting to add this feature to d_ply,
l_ply and a_ply too? As a workaround one can off course use the function
ddply with a dummy return value.

# df & function
	myDf = data.frame(a=factor(1:10), b=factor(1:10), c=1:10)

	tryFun1 = function(myDf){
		Sys.sleep(1)
		return(mean(myDf$c))
	}
# ddply
	ddply(.data=myDf, .variables=c('a', 'b'), .fun=tryFun, .progress='text')
	
	registerDoMC()
	getDoParWorkers()
	ddply(.data=myDf, .variables=c('a', 'b'), .fun=tryFun, .progress='text',
.parallel=TRUE)
# d_ply
	d_ply(.data=myDf, .variables=c('a', 'b'), .fun=tryFun, .progress='text')
	
	registerDoMC()
	d_ply(.data=myDf, .variables=c('a', 'b'), .fun=tryFun, .progress='text',
.parallel=TRUE)


Greetz,

Adi


--
View this message in context: http://r.789695.n4.nabble.com/parallel-computation-in-plyr-1-7-tp4289556p4289833.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list