Try this:
help.search("interpolate")
Then find this:
> library(zoo)
> na.approx(x)
[1] 1.0 4.0 5.0 8.0 6.0 4.0 4.5 5.0 5.0 1.0 2.0 7.0 8.0 9.0 10.5
[16] 12.0 13.5 15.0 6.0 8.0
Hth,
JeeBee.
On Thu, 22 Jun 2006 06:54:53 +0100, Sumanta Basak wrote:
> Hi All,
>
> I need your help in NA handling.
>
> I've following data series.
>
> x<-c(1,4,5,8,NA,4,NA,5,5,1,2,7,8,9,NA,NA,NA,15,6,8)
>
> Now i want to interpolate where NA value persists. Like, between 9 and 5
there are three NA's. So, that should be interpolated like,
>
> 1st NA-> (15-9)/4
> 2nd NA-> 1st NA value + (15-9)/4
>
> Can i get help on this using a 'for' loop. Actually i have huge
daily time series with lots of NA values where i need to make these values.
>
> Please help.
>
> Thanks,
> Sumanta Basak.
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html