Hi:
Look into the na.approx() function in package zoo. The discussion below may
be of help:
http://r.789695.n4.nabble.com/Filling-in-missing-time-samples-with-na-approx-td3063682.html
HTH,
Dennis
On Wed, Jan 5, 2011 at 10:17 PM, Rustamali Manesiya
<rmanesiya@gmail.com>wrote:
> Hello,
>
>
> I am new to R and need some help.
>
> I have data in following format
>
> DATA matrix
> =======================> DateTime o h l c
> 2009-01-01 07:30:00 2 3 4 5
> 2009-01-01 07:33:00 4 2 5 7
>
> I am able to fill the gap using combination of seq and chron
> 2009-01-01 07:30:00
> 2009-01-01 07:31:00
> 2009-01-01 07:32:00
> 2009-01-01 07:33:00
>
> x <- as.numeric(index(DATA[,1]))
> y <- x + 100
> zz <- seq(x,y,1)
>
> How can I refill a new matrix with the values from the corresponding values
> So the data should look like this and then I can apply interpolation on
> this
> data.
> DateTime o h l c
> 2009-01-01 07:30:00 2 3 4 5
> 2009-01-01 07:31:00 NA NA NA NA
> 2009-01-01 07:32:00 NA NA NA NA
> 2009-01-01 07:33:00 4 2 5 7
>
> Or is there a short cut to do direct linear interpolation on the original
> data matrix?
>
> Rusty
>
> [[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.
>
[[alternative HTML version deleted]]