1. Learn
  2. /
  3. Courses
  4. /
  5. Parallel Programming in R

Exercise

Population growth rates with mclapply()

As a Statistical Programmer, you do a lot of bootstrapping in R. One of the routine analyses you conduct is to bootstrap a distribution for the mean population growth rate for different countries across a given time period.

The current code in production uses a PSOCK cluster and parLapply() to parallelize this process for efficient execution. However, this is still running slow for production needs. Your boss has asked you to compare the performance of PSOCK vs. FORK clusters.

gr_list has been loaded in your workspace. Each element of gr_list contains population growth rates for a given country from 2001 to 2021. The bootstrap function, boot_dist(), is also available. parallel and microbenchmark packages have been loaded.

Instructions

100 XP
  • Use the FORK version of parLapply().
  • Supply the list of inputs.
  • Supply the function to apply to each element of input.
  • Specify four cores for the FORK cluster.