na.locf.xts | R Documentation |
xts method replace NA
with most recent non-NA
## S3 method for class 'xts'
na.locf(object, na.rm = FALSE, fromLast = FALSE, maxgap = Inf, ...)
object |
An xts object. |
na.rm |
Logical indicating whether leading/trailing |
fromLast |
Logical indicating whether observations should be carried
backward rather than forward. Default is |
maxgap |
Consecutive runs of observations more than 'maxgap' will
remain |
... |
Unused. |
This is the xts method for the S3 generic na.locf()
. The primary
difference to note is that after the NA
fill action is carried out, the
default it to leave trailing or leading NA
's in place. This is different
than zoo behavior.
An object where each NA
in object
is replaced by the most recent
non-NA prior to it. See na.locf()
for details.
Jeffrey A. Ryan
na.locf()
x <- xts(1:10, Sys.Date()+1:10)
x[c(1,2,5,9,10)] <- NA
x
na.locf(x)
na.locf(x, fromLast=TRUE)
na.locf(x, na.rm=TRUE, fromLast=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.