If I understand you can use approxfun:

DF <- read.table(textConnection("
13/10/2010      A       23
13/10/2010      B       12
13/10/2010      C       124
14/10/2010      A       43
14/10/2010      B       54
14/10/2010      C       65
15/10/2010      A       43
15/10/2010      B       N.A.
15/10/2010      C       65"), na.strings = "N.A.")

f <- approxfun(1:nrow(DF), DF$V3)
DF$V4 <- sapply(seq(nrow(DF)), f)


On Thu, Oct 14, 2010 at 5:17 AM, Santosh Srinivas <
santosh.srini...@gmail.com> wrote:

> Hello,  I have a data frame as below ... in cases where I have N.A. I want
> to use an average of the past date and next date .. any help?
>
> 13/10/2010      A       23
> 13/10/2010      B       12
> 13/10/2010      C       124
> 14/10/2010      A       43
> 14/10/2010      B       54
> 14/10/2010      C       65
> 15/10/2010      A       43
> 15/10/2010      B       N.A.
> 15/10/2010      C       65
>
>
> ----------------------------------------------------------------------------
> --------------------------
> Thanks R-Helpers.
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[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