Learn R Programming

eList (version 0.2.0)

auto_cluster: Quickly Create a Cluster for Parallel Comprehension

Description

A function to quickly create a cluster for use in parallel vector comprehensions. Use makeCluster from the parallel package for greater control. It defaults to making a PSOCK cluster on Windows systems and a Fork cluster on unix-based systems. close_cluster is a wrapper to stopCluster.

Usage

auto_cluster(ncore = detectCores() - 1)

close_cluster(clust)

Arguments

ncore

number of cores/nodes to use. If not specified, it attempts to detect the number of cores available and uses all but 1.

clust

cluster to close the connection to

Value

an object of class c("SOCKcluster", "cluster")

Functions

  • close_cluster: close an open connection to a cluster

Examples

Run this code
# NOT RUN {
## Parallel vector comprehension
cluster <- auto_cluster(2)
Num(for (i in 1:1000) exp(sqrt(i)), clust=cluster)
close_cluster(cluster)

# }

Run the code above in your browser using DataLab