Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

interpolateLinear

Linear Interpolation


Description

Linearly interpolates missing values of a numeric vector. For use with the colapply method of a DTSg object. Other uses are possible, but not recommended. It also serves as an example for writing user defined functions utilising one of the lists with helper data as handed over by some methods of DTSg objects. See DTSg for further information.

Usage

interpolateLinear(.col, roll = Inf, rollends = TRUE, .helpers)

Arguments

.col

A numeric vector.

roll

A positive numeric specifying the maximum size of gaps whose missing values shall be filled. For time series with unrecognised periodicity it is interpreted as 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 as well. See data.table for further information.

.helpers

A list with helper data as handed over by colapply. See colapply for further information.

Value

Returns a numeric vector.

See Also

Examples

# new DTSg object
x <- DTSg$new(values = flow)

# linear interpolation of missing values
## R6 method
x$colapply(fun = interpolateLinear)

## S3 method
colapply(x = x, fun = interpolateLinear)

DTSg

A Class for Working with Time Series Based on 'data.table' and 'R6' with Largely Optional Reference Semantics

v0.7.0
MIT + file LICENSE
Authors
Gerold Hepp [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.