interpolate_time_series: Interpolate time series with error handling

View source: R/10-data-processing.R

interpolate_time_seriesR Documentation

Interpolate time series with error handling

Description

Interpolate time series with error handling

Usage

interpolate_time_series(
  data,
  value_columns,
  target_days,
  method = "linear",
  fill_na_method = "extend",
  validate_input = TRUE
)

Arguments

data

Data frame with Day column and value columns

value_columns

Vector with names of columns to interpolate

target_days

Vector of target days

method

Interpolation method ("linear", "constant", "spline")

fill_na_method

Method to fill missing values ("extend", "zero", "mean")

validate_input

Validate input structure, default TRUE

Value

A data.frame with one row per element of target_days. The first column is Day (integer). Subsequent columns correspond to value_columns, each containing the interpolated numeric values at the requested days. NA values are resolved according to fill_na_method: "extend" fills with the nearest valid value, "zero" replaces with 0, and "mean" uses the column mean.

Examples

temp_data <- data.frame(Day = c(1, 100, 200, 365),
                        Temperature = c(5, 15, 18, 7))
interpolate_time_series(temp_data, value_columns = "Temperature",
                        target_days = 1:365)

fb4package documentation built on May 8, 2026, 1:07 a.m.