locf_value: LOCF / LOCB Lookup

View source: R/nm_helpers.R

locf_valueR Documentation

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_)

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.

Value

numeric vector, length(target_t).


nmw documentation built on May 8, 2026, 9:07 a.m.