Exercise

Extract multiple columns from one instrument

The quantmod package provides functions to extract a single column, and also has functions to extract specific sets of columns.

Recall OHLC stands for open, high, low, close. Now you can guess which columns the OHLC() and HLC() functions extract. There's also an OHLCV() function, which adds the volume column.

These functions are helpful when you need to pass a set of columns to another function. For example, you might need to pass the high, low, and close columns (in that order) to a technical indicator function.

In this exercise, you will use two of these extractor functions on the same DC object you used in the last exercise.

Instructions

100 XP
  • Use one extractor function to create an object named dc_hlc that contains the high, low, and close columns of DC.
  • View the first few rows of dc_hlc.
  • Now extract the open, high, low, close, and volume columns from DC and assign the result to an object named dc_ohlcv.
  • View the first few rows of dc_ohlcv.