Learn R Programming

timeplyr (version 1.1.0)

roll_na_fill: Fast grouped "locf" NA fill

Description

A fast and efficient by-group method for "last-observation-carried-forward" NA filling.

Usage

roll_na_fill(x, g = NULL, fill_limit = Inf)

Value

A filled vector of x the same length as x.

Arguments

x

A vector.

g

An object use for grouping x This may be a vector or data frame for example.

fill_limit

(Optional) maximum number of consecutive NAs to fill per NA cluster. Default is Inf.

Details

Method

When supplying groups using g, this method uses radixorder(g) to specify how to loop through x, making this extremely efficient.

When x contains zero or all NA values, then x is returned with no copy made.