dofuture | R Documentation |
interface to apply some function fn
in parallel on columns of a matrix. It is not logically restricted to mixed-effect applications, hence it can be used more widely. Depending on the nb_cores
argument, parallel or serial computation is performed, calling the future.apply::future_apply
function. A socket cluster is used by default for parallel computations, but a fork cluster can be requested on linux and alike operating systems by using argument cluster_args=list(type="FORK")
.
dofuture(newresp, fn, nb_cores=NULL, fit_env, control=list(),
cluster_args=NULL, debug.=FALSE, iseed=NULL,
showpbar="ignored", pretest_cores="ignored",
... )
newresp |
A matrix on whose columns |
fn |
Function whose first argument is named |
nb_cores |
Integer. Number of cores to use for parallel computations. If >1, a cluster of |
fit_env |
(for socket clusters only:) An environment, or a list, containing variables to be exported on the nodes of the cluster (by |
control |
A list. The only effective control is |
cluster_args |
A list of arguments passed to |
debug. |
(for socket clusters only:) For debugging purposes. Effect, if any, is to be defined by the |
iseed |
Integer, or NULL. If an integer, it is used to initialize |
showpbar , pretest_cores |
Currently ignored; for consistency with |
... |
Further arguments to be passed (unevaluated) to |
The result of calling future.apply
. If the progressr
package is loaded, a side-effect of dofuture
is to show a progress bar with character 'S' or 'P' or 'F' depending on parallelisation status (serial/socket/fork).
dopar
for an alternative implementation of (essentially) the same functionalities, and wrap_parallel
for its differences from dofuture
.
## Not run:
if (requireNamespace("future.apply", quietly = TRUE)) {
# Useless function, but requiring some argument beyond the first
foo <- function(y, somearg, ...) {
if ( is.null(somearg) || TRUE ) length(y)
}
# Whether FORK can be used depends on OS and whether Rstudio is used:
dofuture(matrix(1,ncol=4,nrow=3), foo, fit_env=list(), somearg=NULL,
nb_cores=2, cluster_args=list(type="FORK"))
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.