LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Importing and Managing Financial Data in R

Kurs anzeigen

Anleitung zur Übung

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

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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 = ___)
Code bearbeiten und ausführen