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

Exercise

Healthcare spending with clusterMap()

In a recent healthcare conference, it was claimed that total healthcare expenditure is increasing globally.

You were in attendance, and would like to get some rough estimates to test this claim. You have sourced a dataset that gives you per capita healthcare spending and the population for the year 2000 and onwards. You have two lists: ls_pop and ls_exp. They contain population sizes and per capita healthcare spending, respectively, for each country.

The function total_exp() that takes two arguments: pop or population and exp_pc, per capital healthcare spending. This function returns the total spending in billions of US dollars. You would like to apply this function to ls_pop and ls_exp in parallel. The parallel package has been loaded.

Instructions

100 XP
  • Apply total_exp() in parallel to each element of ls_pop and ls_exp.
  • Specify the list whose elements will be supplied to the pop argument of total_exp().
  • Similarly, specify the list to be supplied to the exp_pc argument of total_exp().