On 6/7/05, Omar Lakkis <[EMAIL PROTECTED]> wrote: > tmp <- c(-1,NA,NA,1,1,NA,NA,1) > > without using a loop, how can I replace all NAs in the list above with > the previous none NA value in the list?
This is known as last occurrence carried forward (LOCF) and is implemented in both the 'zoo' and 'its' packages, e.g. library(zoo) na.locf(tmp) ______________________________________________ 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