nalocf: Faster version of last observation carried forward

View source: R/functions.r

nalocfR Documentation

Faster version of last observation carried forward

Description

This is basically a wrapper around na.locf from the xts package. It avoids the column-by-column copying. Usefull if there are many columns in the xts object.

Usage

nalocf(x, loop = FALSE, ...)

Arguments

x

an xts object

loop

logical. Should the operation be performed as a loop (slower but maybe better for RAM management)

...

further arguments, e.g. na.rm; see na.locf

Value

Returns an xts object

Author(s)

Simon Frey

Examples

    data(runoff)
    # add some NAs
    runoff[2,] <- NA
    index(runoff)[2] <- NA

    a <- nalocf(runoff)
    b <- na.locf(runoff)
    identical(a,b)

freysimon/TigeR documentation built on April 18, 2024, 4:57 p.m.