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.
interpolate_na(x)Numeric vector with NA values replaced by interpolated values.
Numeric vector potentially containing NA values.
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.