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

Connected

Exercise

Column operations with trading volumes

The number of shares traded (sold or bought) in a given time period is the volume. You work for a stock brokerage as a Business Analyst. A matrix of daily changes in volume, mat_stocks, is available for you. Each column contains the change in volume for a stock from the previous day. You want to find out whether the traded volume for these stocks increases consistently for a given period.

The function calculate_runs() is available for you. This function takes two arguments: 1) the daily changes in volume, 2) a single-value of the period (number of days) for which to calculate the run.

You need to apply calculate_runs() to every column of mat_stocks in parallel, specifying five days as the period. The parallel package has been loaded for you.

Instructions

100 XP
  • Export n_days to the cluster.
  • Apply calculate_runs to each column of matrix mat_stocks.
  • Specify the value for the period argument with n_days.