furrr Package in R: Parallel purrr with future Backend
furrr provides drop-in parallel replacements for every purrr map function. Change map() to future_map() and your code runs across multiple CPU cores — no other changes needed.
If your map() call takes minutes because each iteration is slow (API calls, model fitting, file processing), furrr can cut that time proportionally to the number of cores available.
Setup
# Install if needed
# install.packages(c("furrr", "future"))
library(furrr)
library(purrr)
# Tell future to use multiple cores
plan(multisession, workers = 2) # Use 2 workers
cat("Parallel plan active:", nbrOfWorkers(), "workers\n")
Basic Usage: future_map()
The API mirrors purrr exactly. Replace map with future_map.
library(furrr)
plan(multisession, workers = 2)
# Without seed: different results each run
# With seed: reproducible parallel random numbers
results <- future_map_dbl(
1:5,
\(x) rnorm(1),
.options = furrr_options(seed = 123)
)
cat("Reproducible results:", round(results, 3), "\n")
plan(sequential)
Practice Exercises
Exercise 1: Parallel Simulation
Run 100 bootstrap iterations in parallel.
library(furrr)
library(purrr)
plan(multisession, workers = 2)
# Bootstrap the mean of mtcars$mpg
# 1. Create a function that takes an index, samples mtcars with replacement, returns mean(mpg)
# 2. Run it 100 times in parallel with future_map_dbl
# 3. Report the bootstrap confidence interval
plan(sequential)
**Explanation:** Each bootstrap iteration is independent — perfect for parallelization. The seed option ensures reproducible results across parallel workers.
Summary
Feature
Detail
Install
install.packages("furrr")
Setup
plan(multisession, workers = N)
Usage
Replace map with future_map
Cleanup
plan(sequential) when done
Seeds
furrr_options(seed = TRUE)
Progress
.progress = TRUE argument
FAQ
How many workers should I use?
Start with parallel::detectCores() - 1 to leave one core free for your OS. More workers isn't always faster — there's overhead for each worker process.
Does furrr work on Windows?
Yes. plan(multisession) works on all platforms. plan(multicore) only works on Unix/macOS (it uses forking, which Windows doesn't support).
Why is my parallel code slower than sequential?
Parallel overhead (starting workers, sending data, collecting results) exceeds the computation time. This happens when individual iterations are very fast. Parallelism helps when each iteration takes at least a few hundred milliseconds.