Get startedGet started for free

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.

This exercise is part of the course

Importing and Managing Financial Data in R

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Extract the start date of the series


# Extract the end date of the series


# Create a regular date sequence
regular_index <- seq(___, ___, by = "___")

# Create a zero-width xts object
regular_xts <- xts(, order.by = ___)
Edit and Run Code