Hi list,

I have a data frame with a "Date" column and a "Price" column - for example:

Date              Price
01/01/2009     5.45
01/03/2009     6.53
01/04/2009     7.55
01/06/2009     6.76
01/08/2009     4.12
01/18/2009     5.87
...

As you can see, there are days for which I don't have any data.  I would
like to insert rows for missing dates that have values of NA for "Price" -
for example:

Date              Price
01/01/2009     5.45
01/02/2009     NA
01/03/2009     6.53
01/04/2009     7.55
01/05/2009     NA
01/06/2009     6.76
...

With the goal of ultimately converting "Price" to a time series and dealing
with the NAs via the zoo package or something similar.

The first step, however is to add a row for every date.  I have considered
converting "Date" to a time series then using seq() to create a vector with
the appropriate number of rows starting at the appropriate number of days
since epoch, and then using match() to combine columns and add the desired
rows. I'm new to time series in R, but it seems like there should be an
easier way.  I've gotten as far as Google and rseek can take me so any help
would be appreciated.

Bryan

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to