[R] Interpolation in time

From: Anette Nørgaard <anette_at_geoplus.dk>
Date: Thu 06 Oct 2005 - 21:13:04 EST


Can anybody help me write a code on the following data example, which fills out all NA values by using a linear interpolation with the two closest values?  

Doy is day of year (%j).  

Code example:
yr<-c(rep(2000,14))
doy<-c(16:29)
dat<-c(3.2,NA,NA,NA,NA,NA,NA,5.1,NA,NA,NA,NA,NA,4.6) ta<-cbind(yr,doy,dat)  

ta

      yr doy dat
[1,] 2000 16 3.2
[2,] 2000 17 NA
[3,] 2000 18 NA
[4,] 2000 19 NA
[5,] 2000 20 NA
[6,] 2000 21 NA
[7,] 2000 22 NA
[8,] 2000 23 5.1
[9,] 2000 24 NA

[10,] 2000  25  NA
[11,] 2000  26  NA
[12,] 2000  27  NA
[13,] 2000  28  NA
[14,] 2000  29 4.6
 

Anette Norgaard

        [[alternative HTML version deleted]]



R-help@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 Received on Thu Oct 06 21:28:38 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:36 EST