Learn R Programming

chillR (version 0.75)

interpolate_gaps: Linear gap interpolation

Description

This function linearly interpolates gaps in data series, such as daily temperature records.

Usage

interpolate_gaps(x)

Value

interp

numeric vector, in which all gaps in x have been linearly interpolated

missing

boolean vector of the same length as interp and x, which marks all gaps in x as TRUE

Arguments

x

a numeric vector, or a vector that can be coerced with as.numeric. Missing values are either NA or non-numeric values.

Author

Eike Luedeling

Details

The function returns a list with two elements: interp is a new vector, in which all gaps in x have been linearly interpolated. missing is a second vector, which contains information on which values were filled in by interpolation.

References

Luedeling E, Kunz A and Blanke M, 2013. Identification of chilling and heat requirements of cherry trees - a statistical approach. International Journal of Biometeorology 57,679-689.

Examples

Run this code

weather<-make_all_day_table(KA_weather)
Tmin_int<-interpolate_gaps(KA_weather[,"Tmin"])
weather[,"Tmin"]<-Tmin_int$interp
weather[,"Tmin_interpolated"]<-Tmin_int$missing

Tmax_int<-interpolate_gaps(KA_weather[,"Tmax"])
weather[,"Tmax"]<-Tmax_int$interp
weather[,"Tmax_interpolated"]<-Tmax_int$missing

#this function is integrated into the fix_weather function, but it can also be run on its own.


Run the code above in your browser using DataLab