foreach と doMC を使用して、並行して実行しているときに画面を取得cat
および/または画面に出力する方法はありますか? message
例えば:
> library(foreach)
>
> tmp <- foreach(i=1:3) %do%
+ cat("sqrt(i) =", sqrt(i), "\n")
sqrt(i) = 1
sqrt(i) = 1.414214
sqrt(i) = 1.732051
>
> tmp <- foreach(i=1:3) %do%
+ message("i^2 =", i^2, "\n")
i^2 =1
i^2 =4
i^2 =9
>
> library(doMC)
> registerDoMC(2)
>
> tmp <- foreach(i=1:3) %dopar%
+ cat("sqrt(i) =", sqrt(i), "\n")
>
> tmp <- foreach(i=1:3) %dopar%
+ message("i^2 =", i^2, "\n")
>
> sessionInfo()
R Under development (unstable) (2014-01-29 r64898)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets
[7] methods base
other attached packages:
[1] doMC_1.3.2 iterators_1.0.6 foreach_1.4.1
loaded via a namespace (and not attached):
[1] codetools_0.2-8 compiler_3.1.0 tools_3.1.0
ありがとう、
マックス