2
在並行處理中,我是一個新手,我想提供一些建議。R和並行化
我的[R方案具有結構如下:
Data reading
Preliminary calculations
vector1 <- array(NA,sim=nsim)
vector2 <- array(NA,sim=nsim)
for (i in 1:nsim)
{
some calculations involving some global variables and
whose results are saved in vector1 and vector2
}
Final calculations using vector1 and vector2
這個循環是非常耗時的,我想知道其中R包可以提供我並行化的最佳途徑。你有什麼想法嗎?提前致謝。
該循環很容易重寫以使用'foreach'軟件包。在Linux上,我使用'foreach'和'doMC'後臺有很好的經驗。請參閱[本簡介](http://cran.r-project.org/web/packages/doMC/vignettes/gettingstartedMC.pdf)。 – Roland
但是,我懷疑這個循環可以被重寫,效率更高。 – Roland
你能重寫一個lapply調用的循環嗎?如果是的話,你可以使用parLapply(從包並行)。 –