View source: R/10-data-processing.R
| interpolate_time_series | R Documentation |
Interpolate time series with error handling
interpolate_time_series(
data,
value_columns,
target_days,
method = "linear",
fill_na_method = "extend",
validate_input = TRUE
)
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 |
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.