我发布这个问题是为了询问如何在Windows XP机器上优化R中多个处理器的使用.
目前我正在创建4个脚本(每个脚本用例如for(i in 1:100)和(i in 101:200)等),我同时在4个不同的R会话中运行.这似乎使用了所有可用的cpu.
但是,我希望这样做更有效率.一种解决方案可能是使用"doMC"和"foreach"软件包,但这在Windows机器上的R中是不可能的.
例如
library("foreach")
library("strucchange")
library("doMC") # would this be possible on a windows machine?
registerDoMC(2) # for a computer with two cores (processors)
## Nile data with one breakpoint: the annual flows drop in 1898
## because the first Ashwan dam was built
data("Nile")
plot(Nile)
## F statistics indicate one breakpoint
fs.nile <- Fstats(Nile ~ 1)
plot(fs.nile)
breakpoints(fs.nile) # , hpc = "foreach" --> It would be great to test this.
lines(breakpoints(fs.nile))
Run Code Online (Sandbox Code Playgroud)
任何解决方案或建议?