我发这个问题是为了寻求关于如何在Windows XP机器上优化使用多处理器的建议。
目前,我正在创建4个脚本(每个脚本都有例如for (i in 1:100)和(i in 101:200)等),并在同时运行的4个不同的R会话中运行它们。这似乎使用了所有可用的CPU。
但是,我希望能更加高效地完成这项任务。一种解决方案可能是使用“doMC”和“foreach”包,但这在Windows机器上的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))
有什么解决方案或建议吗?