ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Parallel Programming in R

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Plan a multisession of four workers
plan(___, workers = ___)

# Apply rank_walmart to each element of ls_stocks
___(___, ___)

# Revert to sequential plan
plan(___)
Editar y ejecutar código