Replaces each missing value with the most recent present value prior to it (Last Observation Carried Forward LOCF). Optionally this can also be done starting from the back of the series (Next Observation Carried Backward  NOCB).
1  na.locf(x, option = "locf", na.remaining = "rev")

x 
Numeric Vector ( 
option 
Algorithm to be used. Accepts the following input:

na.remaining 
Method to be used for remaining NAs.

Replaces each missing value with the most recent present value prior to it (Last Observation Carried Forward LOCF). This can also be done from the reverse direction starting from the back (Next Observation Carried Backward  NOCB). Both options have the issue, that NAs at the beginning (or for nocb at the end) of the time series cannot be imputed (since there is no last value to be carried forward present yet). In this case there are remaining NAs in the imputed time series. Since this only concerns very few values at the beginning of the series, na.remaining offers some quick solutions to get a series without NAs back.
Vector (vector
) or Time Series (ts
) object (dependent on given input at parameter x)
Steffen Moritz
na.interpolation
,
na.kalman
,
na.ma
, na.mean
,
na.random
, na.replace
,
na.seadec
, na.seasplit
1 2 3 4 5 6 7 8 9 10 11 
Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.