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.
Este exercício faz parte do curso
Importing and Managing Financial Data in R
Instruções do exercício
- 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_index
containing a sequence of date-times fromstart_date
toend_date
by day. - Use the
xts()
constructor to create a zero-width xts object. Store it inregular_xts
.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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 = ___)