na_locf: Function for carrying last observation forwards.

View source: R/na_locf.R

na_locfR Documentation

Function for carrying last observation forwards.

Description

Used to replace each NA with the most recent non-NA prior to it. locf is a simple wrapper for zoo::na.locf.

Usage

na_locf(x, na.rm = FALSE)

Arguments

x

Input vector.

na.rm

Should leading NAs be removed? Default is FALSE.

Value

Vector of same data type and length of x.

Author(s)

Stuart K. Grange

Examples

## Not run: 

# Push observations forwards, in a data frame
data_income$income_chunk <- na_locf(data_income$income_chunk)


## End(Not run)


skgrange/threadr documentation built on May 11, 2024, 12:16 p.m.