Coerce an Object to a Cluster Object

as.cluster(x, ...)

# S3 method for cluster
as.cluster(x, ...)

# S3 method for list
as.cluster(x, ...)

# S3 method for SOCKnode
as.cluster(x, ...)

# S3 method for SOCK0node
as.cluster(x, ...)

# S3 method for RichSOCKnode
as.cluster(x, ...)

# S3 method for cluster
c(..., recursive = FALSE)

Arguments

x

An object to be coerced.

...

Additional arguments passed to the underlying coercion method. For c(...), the clusters and cluster nodes to be combined.

recursive

Not used.

Value

An object of class cluster.

c(...) combine multiple clusters and / or cluster nodes into one cluster returned as an of class cluster. A warning will be produced if there are duplicated nodes in the resulting cluster.

Examples

cl1 <- makeClusterPSOCK(2, dryrun = TRUE)
#> ----------------------------------------------------------------------
#> Manually, start worker #1 on local machine ‘localhost’ with:
#> 
#>   '/home/henrik/shared/software/CBI/R-4.3.1-gcc11/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'options(socketOptions = "no-delay")' -e 'workRSOCK <- tryCatch(parallel:::.workRSOCK, error=function(e) parallel:::.slaveRSOCK); workRSOCK()' MASTER=localhost PORT=11568 OUT=/dev/null TIMEOUT=2592000 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential
#> 
#> ----------------------------------------------------------------------
#> Manually, start worker #2 on local machine ‘localhost’ with:
#> 
#>   '/home/henrik/shared/software/CBI/R-4.3.1-gcc11/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'options(socketOptions = "no-delay")' -e 'workRSOCK <- tryCatch(parallel:::.workRSOCK, error=function(e) parallel:::.slaveRSOCK); workRSOCK()' MASTER=localhost PORT=11568 OUT=/dev/null TIMEOUT=2592000 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential
#> 
cl2 <- makeClusterPSOCK(c("n1", "server.remote.org"), dryrun = TRUE)
#> ----------------------------------------------------------------------
#> Manually, (i) login into external machine ‘n1’:
#> 
#>   '/usr/bin/ssh' -R 11138:localhost:11138 n1
#> 
#> and (ii) start worker #1 from there:
#> 
#>   '/home/henrik/shared/software/CBI/R-4.3.1-gcc11/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'options(socketOptions = "no-delay")' -e 'workRSOCK <- tryCatch(parallel:::.workRSOCK, error=function(e) parallel:::.slaveRSOCK); workRSOCK()' MASTER=localhost PORT=11138 OUT=/dev/null TIMEOUT=2592000 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential
#> 
#> Alternatively, start worker #1 from the local machine by combining both steps in a single call:
#> 
#>   '/usr/bin/ssh' -R 11138:localhost:11138 n1 "'/home/henrik/shared/software/CBI/R-4.3.1-gcc11/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'options(socketOptions = \"no-delay\")' -e 'workRSOCK <- tryCatch(parallel:::.workRSOCK, error=function(e) parallel:::.slaveRSOCK); workRSOCK()' MASTER=localhost PORT=11138 OUT=/dev/null TIMEOUT=2592000 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential"
#> 
#> ----------------------------------------------------------------------
#> Manually, (i) login into external machine ‘server.remote.org’:
#> 
#>   '/usr/bin/ssh' -R 11139:localhost:11138 server.remote.org
#> 
#> and (ii) start worker #2 from there:
#> 
#>   'Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'options(socketOptions = "no-delay")' -e 'workRSOCK <- tryCatch(parallel:::.workRSOCK, error=function(e) parallel:::.slaveRSOCK); workRSOCK()' MASTER=localhost PORT=11139 OUT=/dev/null TIMEOUT=2592000 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential
#> 
#> Alternatively, start worker #2 from the local machine by combining both steps in a single call:
#> 
#>   '/usr/bin/ssh' -R 11139:localhost:11138 server.remote.org "'Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'options(socketOptions = \"no-delay\")' -e 'workRSOCK <- tryCatch(parallel:::.workRSOCK, error=function(e) parallel:::.slaveRSOCK); workRSOCK()' MASTER=localhost PORT=11139 OUT=/dev/null TIMEOUT=2592000 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential"
#> 
cl <- c(cl1, cl2)
#> Warning: The combined cluster contains 1 duplicated nodes
print(cl)
#> Socket cluster with 2 nodes where 2 nodes are on host ‘NA’ (R version and platform not queried)