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 ______________________________________________ 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.