Session Ready
Exercise

Exploring the cluster object

In this exercise, you will explore the cluster object created by makeCluster(). In addition, you will use clusterCall(), which evaluates a given function on all workers. This can be useful, for example, when retrieving information from workers.

clusterCall() takes two arguments: the cluster object and the function to apply to each worker node. Just like lapply(), the function is passed without parentheses.

Here, we will use clusterCall() to determine the process ID of the workers, which is equivalent to finding process IDs of R sessions spawned by the master. Such info could be used for process management, including things outside of R.

Instructions 1/2
undefined XP
  • 1
  • 2
  • Load the parallel package and create a cluster object cl with four workers.
  • Investigate the str()ucture of cl.