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

Exercise

Ranking stocks with furrr

Investment banks rank each stock based on factors like growth, valuation, etc. These rankings then inform the allocation of money to each stock.

You have been hired by a major investment bank. Looking to invest in Walmart, the bank wants to investigate the price stability of Walmart stock. In your workspace, you have a list of data frame, ls_stocks. Each element of this list is a data frame that contains the percentage variation in stock prices.

The financial analyst has written a function, rank_walmart(), that will perform the ranking on one data frame and output a whole number for the rank. You need to apply this function to each element of ls_stocks in parallel using the furrr package. furrr has been loaded for you.

Instructions

100 XP
  • Plan a multisession of four workers.
  • Apply rank_walmart() to each element of ls_stocks using the correct future_map variant for an integer output.
  • Revert to a sequential plan when calculations are done.