Hi R-helpers

I'm looking for a vectorised function which does missing value replacement
as in last observation carried forward in the zoo package but instead of a
locf, I would like the locf function to add +1 to each time a missing value
occurred. See below for an example.

> require(zoo)
> x <- 5:15
> x[4:7] <- NA
> coredata(na.locf(zoo(x)))
 [1]  5  6  7  7  7  7  7 12 13 14 15
But what I need is
5  6  7  7+1  7+1+1  7+1+1+1  7+1+1+1+1 12 13 14 15
to obtain
[1]  5  6  7  8  9 10 11 12 13 14 15
I could program this in C but if anyone has already done this I would be
interested in seeing their vectorized solution.

thanks,
Jan

-- 
groeten/kind regards,
Jan

Jan Wijffels
Statistical Data Miner
www.bnosac.be  | +32 486 611708

        [[alternative HTML version deleted]]

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

Reply via email to