Exercise

Extract one column from one instrument

The quantmod package provides several helper functions to extract specific columns from an object, based on the column name. The Op(), Hi(), Lo(), Cl(), Vo(), and Ad() functions can be used to extract the open, high, low, close, volume, and adjusted close column, respectively.

In this exercise, you will use two of these functions on an xts object named DC. The DC object contains fictitious DataCamp OHLC (open, high, low, close) stock prices created by randomizing some real financial market data. DC is similar to the xts objects created by getSymbols().

While it's not necessary to complete the exercise, you can learn more about all the extractor functions from help("OHLC.Transformations").

Instructions

100 XP
  • Use the appropriate extractor function to create an object named dc_close that contains only the close column of DC.
  • View the first few rows of dc_close.
  • Now extract the volume column from DC and assign it to an object named dc_volume.
  • View the first few rows of dc_volume.