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.
This exercise is part of the course
Parallel Programming in R
Exercise instructions
- Plan a multisession of four workers.
- Apply
rank_walmart()
to each element ofls_stocks
using the correctfuture_map
variant for an integer output. - Revert to a sequential plan when calculations are done.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plan a multisession of four workers
plan(___, workers = ___)
# Apply rank_walmart to each element of ls_stocks
___(___, ___)
# Revert to sequential plan
plan(___)