interpolateLinear | R Documentation |
Linearly interpolates missing values of a numeric vector. For use with the
colapply
method of DTSg
objects. Other uses are possible, but not
recommended.
This function
mainly serves as an example for writing user defined
function
s utilising one of the list
s with helper data handed over by
some of the methods of DTSg
objects.
interpolateLinear(.col, roll = Inf, rollends = TRUE, .helpers)
.col |
A numeric vector. |
roll |
A positive numeric specifying the maximum size of gaps whose missing values shall be interpolated. For time series with unrecognised periodicity it is interpreted in seconds and for time series with recognised periodicity it is multiplied with the maximum time difference between two subsequent time steps in seconds. Thus, for regular time series it is the number of time steps and for irregular it is an approximation of it. |
rollends |
A logical specifying if missing values at the start and end
of the time series shall be filled. See |
.helpers |
A |
Returns a numeric vector.
# new DTSg object
x <- DTSg$new(values = flow)
# linear interpolation of missing values
## R6 method
x$colapply(fun = interpolateLinear)$print()
## S3 method
print(colapply(x = x, fun = interpolateLinear))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.