Re: [R] Trick to replace NA

2012-11-22 Thread Jorge I Velez
Dear Marc, Try require(zoo) na.locf(a) HTH, Jorge.- On Thu, Nov 22, 2012 at 11:56 PM, Marc Girondot <> wrote: > Dear members, > > I have a series of values in a vector and some value are missing and > replaced with NA. > For example: > a <- c(27, 25, NA, NA, 24, 26, 27, NA, 26) > I would like

Re: [R] Trick to replace NA

2012-11-22 Thread R. Michael Weylandt
Take a look at na.locf() in the zoo package. (LOCF = last observation carried forward) RMW On Thu, Nov 22, 2012 at 12:56 PM, Marc Girondot wrote: > Dear members, > > I have a series of values in a vector and some value are missing and > replaced with NA. > For example: > a <- c(27, 25, NA, NA,

[R] Trick to replace NA

2012-11-22 Thread Marc Girondot
Dear members, I have a series of values in a vector and some value are missing and replaced with NA. For example: a <- c(27, 25, NA, NA, 24, 26, 27, NA, 26) I would like to replace the NAs with the value taken from the previous value that is non-NA. The output would be in this case: 27 25 25