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

Exercise

Create a zero-width and regular xts object

In order to create regular data from an irregular dataset, the first thing you need is a regular sequence of date-times that span the dates of your irregular dataset. A "regular" sequence of date-times has equally-spaced time points.

In this exercise, you will use the irregular_xts object to create a zero-width xts object that has a regular daily index. A zero-width xts object has an index of date-times, but no data columns.

Instructions

100 XP
  • Use the start() function to create an object named start_date.
  • Use the end() function to create an object named end_date.
  • Use the seq() function to create an object named regular_index containing a sequence of date-times from start_date to end_date by day.
  • Use the xts() constructor to create a zero-width xts object. Store it in regular_xts.