首页 > 解决方案 > 在 ROUT 文件中屏蔽来自 foreach 的“启动工作人员”消息

问题描述

我的代码目前看起来像这样

results= foreach(i=seq(1,n),.combine='c') %dopar% {
               require('Matrix',quietly=TRUE)
               start_time=Sys.time()
               Q[i]=some_function(1,2,3)
               end_time=Sys.time()
               print(end_time-start_time)
   }

我正在并行计算一些东西,并希望能够在每个并行进程中打印到 ROUT 文件。问题是我的 ROUT 文件充满了以下内容

starting worker pid=82688 on localhost:11668 at 10:57:10.347
starting worker pid=82672 on localhost:11668 at 10:57:10.347
starting worker pid=82677 on localhost:11668 at 10:57:10.347
starting worker pid=82680 on localhost:11668 at 10:57:10.347
starting worker pid=82669 on localhost:11668 at 10:57:10.346

由于我的代码涉及我多次调用 foreach 这使得解析 ROUT 文件变得非常困难

有没有办法从foreach包中的 R outfile 中静音“starting worker pid = ...”行?

标签: rparallel-processingparallel-foreach

解决方案


推荐阅读