approxTime: Linear Interpolation with Complete Matrices or Data Frames In rSALMO: Simulation of ecological lake models

Description

Return a data frame, matrix or vector which linearly interpolates data from a given matrix or data frame.

Usage

 ```1 2 3 4 5 6 7 8 9``` ```approxTime(x, xout, ...) approxTime1(x, xout, rule = 1) approxTimeEq(x, xout, ...) approxTimeEq1(x, xout, rule = 1) findIndexEq(x, xout, rule = 1) ```

Arguments

 `x` a matrix or data frame with numerical values giving coordinates of points to be interpolated. The first column needs to be in ascending order and is interpreted as independent variable (e.g. time), the remaining columns are used as dependent variables. `xout` a vector (or single value for `approxTime1`) of independend values specifying where interpolation has to be done. `...` optional parameters passed to `approx`. `rule` an integer describing how interpolation is to take place outside the interval [min(x), max(x)]. If `rule` is 1 then `NA`s are returned for such points and if it is 2, the value at the closest data extreme is used.

Details

The functions can be used for linear interpolation with a complete matrix or data frame. This can be used for example in the main function of an `odeModel` to get input values at a specified time `xout`. Versions `approxTime1`, `approxTimeEq` amd `approxTimeEq1` are less flexible (only one single value for `xout` or/and equidistant values of of time in `x` and only linear interpolation) but have increased performance. All interpolation functions are faster if `x` is a matrix instead of a data frame.

Value

`approxTime` returns a matrix resp. data frame of the same structure as `x` containing data which interpolate the given data with respect to `xout`. `approxTime1` is a performance optimized special version with less options than the original `approx` function. It returns an interpolated vector.

`approxfun`
 ```1 2``` ```inputs <- data.frame(time = 1:10, y1 = rnorm(10), y2 = rnorm(10, mean = 50)) input <- approxTime(inputs, c(2.5, 3), rule = 2) ```