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.
Cet exercice fait partie du cours
Importing and Managing Financial Data in R
Instructions
- Use the
start()function to create an object namedstart_date. - Use the
end()function to create an object namedend_date. - Use the
seq()function to create an object namedregular_indexcontaining a sequence of date-times fromstart_datetoend_dateby day. - Use the
xts()constructor to create a zero-width xts object. Store it inregular_xts.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de 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 = ___)