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(modelsummary)
fit1 <- lm(mpg ~ cyl, data = mtcars)
fit2 <- lm(mpg ~ cyl + hp, data = mtcars)
models <- list(Model1 = fit1, Model2 = fit2)
modelsummary(models) |> futurize()
The modelsummary package creates customizable tables and plots to summarize statistical models side-by-side. For example,
library(futurize)
plan(multisession)
library(modelsummary)
## fit multiple linear models
fit1 <- lm(mpg ~ cyl, data = mtcars)
fit2 <- lm(mpg ~ cyl + hp, data = mtcars)
models <- list(Model1 = fit1, Model2 = fit2)
## generate modelsummary table in parallel
tbl <- modelsummary(models, output = "data.frame") |> futurize()
print(tbl)
will parallelize model summary statistics extraction, given that we have set up parallel workers, e.g.
plan(multisession)
The built-in multisession backend parallelizes on your local
computer and works on all operating systems. There are other
parallel backends to choose from, including alternatives to
parallelize locally as well as distributed across remote machines,
e.g.
plan(future.mirai::mirai_multisession)
and
plan(future.batchtools::batchtools_slurm)
The following modelsummary functions are supported by futurize():
modelsummary() with seed = TRUE as the defaultmsummary() with seed = TRUE as the defaultmodelplot() with seed = TRUE as the default