locf: Impute Missing Vector Values

locfR Documentation

Impute Missing Vector Values

Description

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 NA's. bakfor() does the reverse.

Usage

locf(x)

forbak(x)

bakfor(x)

nocb(x)

Arguments

x

a vector possibly with some missing values and some non-missing values

Value

a vector like x

Functions

  • forbak(): forbak locf followed by nocb

  • bakfor(): bakfor nocb followed by locf

  • nocb(): nocb next observation carried backward

See Also

Other util: %contains%(), as.best.default(), as.best(), enclose(), padded(), parens(), pool(), runhead(), text2decimal()

Other util: %contains%(), as.best.default(), as.best(), enclose(), padded(), parens(), pool(), runhead(), text2decimal()

Other util: %contains%(), as.best.default(), as.best(), enclose(), padded(), parens(), pool(), runhead(), text2decimal()

Other util: %contains%(), as.best.default(), as.best(), enclose(), padded(), parens(), pool(), runhead(), text2decimal()

Examples

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))

bergsmat/nonmemica documentation built on Sept. 15, 2023, 9:22 a.m.