[R] Error on using lag function

Peter Ehlers ehlers at ucalgary.ca
Fri Jan 29 00:32:47 CET 2010


Did you try it? I said

library(zoo)
na.locf(P, fromLast=TRUE)

Note the 'fromLast=TRUE'; that tells na.locf() to use the
reverse of your vector.

What I meant by

"You'll have to decide what to do if the last value is NA"
is that you'll need to decide what to do if your vector
ends with a NA, say:

v
[1]  1  9 NA  4  5 20 NA 15  8 NA

  -Peter Ehlers

anna wrote:
> Hi Peter, thank you for helping. The thing is don't want to it replace it
> with the last value but with the next value
> 
> -----
> Anna Lippel

-- 
Peter Ehlers
University of Calgary



More information about the R-help mailing list