我试图让 ddply 在我的 mac 上并行运行。我使用的代码如下:
library(doMC)
library(ggplot2) # for the purposes of getting the baseball data.frame
registerDoMC(2)
> system.time(ddply(baseball, .(year), numcolwise(mean)))
user system elapsed
0.959 0.106 1.522
> system.time(ddply(baseball, .(year), numcolwise(mean), .parallel=TRUE))
user system elapsed
2.221 2.790 2.552
为什么运行 .parallel=TRUE 时 ddply 会变慢?我在网上搜索无济于事。我也试过registerDoMC()
了,结果是一样的。