interpolateCond: Interpolate conditions

interpolateCondR Documentation

Interpolate conditions

Description

Interpolate variables of conditions

Usage

interpolateCond(conditions, method)

Arguments

conditions

data.frame with columns named time and variables expected to correspond to those of the model.

method

character corresponding to the name of the interpolating method. Available methods include constant, linear and spline (for natural cubic splines).

Details

The function is a wrapper of approxfun.

Value

Return a list of functions that interpolate variable according to time. Functions have only v as an argument which represent the time vector at which the function is to be interpolated. The names attribute of the list correspond to the variable names.

Examples

#Example of a call with two variables
conditions <- data.frame(time = seq(0,30,length.out = 10), temp = rnorm(10, 10, 5), rh = rnorm(10, 10, 5))
f <- interpolateCond(conditions, method = "constant")
f
#Plotting the result for temp 
plot(conditions$time,conditions$temp)
x <- seq(0,30,length.out = 100)
lines(x,f$temp(x), lty = 1)
f <- interpolateCond(conditions, method = "spline")
#Plotting the result for temp 
plot(conditions$time,conditions$temp)
x <- seq(0,30,length.out = 100)
lines(x,f$temp(x), lty = 1)

aleblancbio/timescale documentation built on Aug. 27, 2022, 3:01 p.m.