The futurize package allows you to easily turn sequential code
into parallel code by piping the sequential code to the futurize()
function. Easy!
library(futurize)
plan(multisession)
library(ez)
data(ANT)
rt <- ezBoot(
data = ANT,
dv = rt,
wid = subnum,
within = .(cue, flank),
between = group,
iterations = 1e3
) |> futurize()
This vignette demonstrates how to use this approach to parallelize
ez functions such as ezBoot(), ezPerm(), and ezPlot2().
The functions ezBoot(), ezPerm(), and ezPlot2() support parallel
evaluation via the parallel argument. By piping to futurize(), you
can leverage any future-based parallel backend for these computations.
The ezBoot() function computes bootstrap resampled predictions for
each cell in an experimental design. We can parallelize this as:
library(futurize)
plan(multisession)
library(ez)
data(ANT)
rt <- ezBoot(
data = ANT,
dv = rt,
wid = subnum,
within = .(cue, flank),
between = group,
iterations = 1e3
) |> futurize()
This will distribute the bootstrap iterations across the available parallel workers.
The ezPerm() function performs a non-parametric factorial
permutation test, and can be parallelized as:
library(futurize)
plan(multisession)
library(ez)
library(plyr)
data(ANT)
cell_stats <- ddply(
.data = ANT,
.variables = .(subnum, group, cue, flank),
.fun = function(x) {
data.frame(mrt = mean(x$rt[x$error == 0]))
}
)
gmrt <- ddply(
.data = cell_stats,
.variables = .(subnum, group),
.fun = function(x) {
data.frame(mrt = mean(x$mrt))
}
)
mean_rt_perm <- ezPerm(
data = gmrt,
dv = mrt,
wid = subnum,
between = group,
perms = 1e3
) |> futurize()
The following ez functions are supported by futurize():
ezBoot() with seed = TRUE as the defaultezPerm() with seed = TRUE as the defaultezPlot2()
Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.
This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.