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

Connected

Exercise

The furrr configuration

You work for a public health consultancy. Your boss wants you to write parallel code to calculate different quantiles of the life expectancy distribution.

In your workspace, you have ls_exp, a list of vectors. Each element of this list is a vector of life expectancy estimates for every country. The calc_quant() function to calculate quantiles is available for you. This function takes two arguments, life_exp, the life expectancy vector, and quant, a static value for the quantile to be calculated. The value to be supplied to the second argument is stored as my_quant in your workspace.

You need to apply calc_quant() to each element of ls_exp using the furrr package.

furrr has been loaded for you.

Instructions

100 XP
  • Create a configuration for furrr functions to specify my_quant as a global variable.
  • In the future_map() call, map calc_quant() to every element of ls_exp.
  • Supply the exported global variable to the quant argument of calc_quant().
  • Supply the configuration created earlier to the .options argument.