Hi Bill
Many thanks for your help.
Cheers
R
-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: 10 July 2012 17:22
To: Raghuraman Ramachandran; r-help@r-project.org
Subject: RE: Help with vectors and rollapply
It looks like you already have the zoo package loaded so
It looks like you already have the zoo package loaded so you can use its
na.locf(),
which replaces NA's with the last non-NA value. Convert the 0s to NAs with
replace() and feed the result into na.locf():
a <- c(-2,0,0,0,1,0,0,3,0,0,-4)
aOut <- c(-2,-2,-2,-2,1,1,1,3,3,3,-4)
na.locf(replace
2 matches
Mail list logo