r - Simple working example of ddply() in parallel on Windows -
i've been searching around simple working example of using ddply() in parallel. i've installed "foreach" package, when call ddply( .parallel = true) warning "no parallel backend registered")
can provide simple working example of using ddply in parallel?
here's simple working example:
> df <- data.frame(val=1:10, ind=c(rep(2, 5), rep(3, 5))) > library(dosnow) > registerdosnow(makecluster(2, type = "sock")) > system.time(print(ddply(df, .(ind), function(x) { sys.sleep(2); sum(x) }, .parallel=false))) ind v1 1 2 25 2 3 55 user system elapsed 0.00 0.00 4.01 > system.time(print(ddply(df, .(ind), function(x) { sys.sleep(2); sum(x) }, .parallel=true))) ind v1 1 2 25 2 3 55 user system elapsed 0.02 0.00 2.02
Comments
Post a Comment