locf: Impute Missing Vector Values

Description Usage Arguments Details Value Author(s) References Examples

Description

Impute NA values using other values in the vector.

Usage

1
2
3
4
locf(x)
forbak(x)
bakfor(x)
nocb(x)

Arguments

x

A vector with some missing values and some non-missing values.

Details

locf implements “last observation carried forward”: NA's are imputed with the most recent non-NA value. nocb is the complement: “next observation carried backward”: NA's are imputed with the next non-NA value. forbak first executes locf, then nocb, so that even leading NAs are imputed. If even one non-NA value is present, forbak should not return any NAs. bakfor does the reverse.

Value

A vector of the same class as x.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

Examples

1
2
3
locf(c(NA,1,2,NA,NA,3,NA,4,NA))
nocb(c(NA,1,2,NA,NA,3,NA,4,NA))
forbak(c(NA,1,2,NA,NA,3,NA,4,NA))

metrumrg documentation built on May 2, 2019, 5:55 p.m.