Learn R Programming

SignalY (version 1.1.1)

interpolate_na: Linear Interpolation for Missing Values

Description

Performs linear interpolation to fill missing values in a numeric vector. Handles edge cases where NA values occur at the beginning or end of the vector by using nearest non-NA values.

Usage

interpolate_na(x)

Value

Numeric vector with NA values replaced by interpolated values.

Arguments

x

Numeric vector potentially containing NA values.

Details

The interpolation uses stats::approx with linear method. For leading NAs, the first non-NA value is used. For trailing NAs, the last non-NA value is used. This ensures no NA values remain in the output.