roll_na_fill: Fast grouped "locf" 'NA' fill

View source: R/roll_na_fill.R

roll_na_fillR Documentation

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)

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.

Value

A filled vector of x the same length as x.


timeplyr documentation built on April 3, 2025, 6:15 p.m.