Learn R Programming

nmw (version 0.3.0)

locf_value: LOCF / LOCB Lookup

Description

For each target time, return the most-recent source value at source_t <= target_t (LOCF). If no preceding source exists, return the earliest source_v at source_t > target_t (LOCB). Empty source returns fallback for all targets.

Usage

locf_value(target_t, source_t, source_v, fallback = NA_real_)

Value

numeric vector, length(target_t).

Arguments

target_t

vector of target times (numeric or POSIXct).

source_t

vector of source times (same type as target_t).

source_v

numeric vector of source values, parallel to source_t.

fallback

value used when no source is available. Default NA.