Re: [R] without a loop

From: Gabor Grothendieck <>
Date: Wed 08 Jun 2005 - 01:19:22 EST

On 6/7/05, Omar Lakkis <> 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.

na.locf(tmp) mailing list PLEASE do read the posting guide! Received on Wed Jun 08 01:34:50 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:27 EST