I’m using the timeSeries package, and especially the align function. My data are spurious and I want to fill the NAs by propagating the last available value. But it seems that align() doesn’t go until the end of the sample if it finishes with an NA.
An example: I have a non-aligned time series
> notAligned
GMT
TS.1 TS.2 TS.3 TS.4
2011-02-03 NA 1 4 8
2011-02-04 1 NA 2 NA
2011-02-07 5 6 NA NA
2011-02-08 NA 2 NA 9
If I use the align function, it returns this
> align(notAligned)
GMT
TS.1 TS.2 TS.3 TS.4
2011-02-03 NA 1 4 8
2011-02-04 1 1 2 8
2011-02-07 5 6 NA 8
2011-02-08 NA 2 NA 9
It correctly fills TS.2 on the 4th and TS.4 on the 4th and 7th, but doesn’t fill TS.1 on the 8th with 5, or TS.3 on the 7th and 8th with 2. I would expect align to fill them…
Did I misunderstand the function? Is there a way to work around this?
Thanks for your help
I have no idea why
timeSeries::aligndoesn’t work, but I would just usezoo::na.locf: