How do I get node or process id when using doParallel?

foreach, parallel-processing, r

Solution

After a lot of trial and error, I found the following to work:

foreach(i = 1:12, .combine=c) %dopar% {
  Sys.getpid()
}

This gives a unique process ID for each of the nodes, which can be used as the node id.

Problem

I am running a parallel process on a 12 node cluster. And was wondering if there is a way to get the node-id or node-number or node-name during a `foreach` call? Something like this: ``` foreach(i = 1:12, .combine=c) %dopar% {node.name()} ``` This will be helpful in processing the files.

Original source