1. Learn
  2. /
  3. Courses
  4. /
  5. Importing and Managing Financial Data in R

Exercise

Aggregate irregular intra-day data

Intraday data can be huge, with hundreds of thousands of observations per day, millions per month, and hundreds of millions per year. These datasets often need to be aggregated before you can work with them.

You learned how to aggregate daily data in the Introduction to xts and zoo course. This exercise will use to.period() to aggregate intraday data to an OHLC series. You often need to specify both period and k arguments to aggregate intraday data.

The intraday_xts object contains one trading day of random data.

Instructions

100 XP
  • Use to.period() to convert intraday_xts into a 5-second price series called xts_5sec.
  • Use to.period() to convert intraday_xts into a 10-minute price series called xts_10min.
  • Use to.period() to convert intraday_xts into a 1-hour price series called xts_1hour.