timeScale | R Documentation |
Evaluate the time elapsed between two bounds (x1
, x2
) into a scaled domain given a rate model and condtions that represent its variables.
timeScale( x1, x2, model, conditions, param = list(), control = list(), interpolation = "constant", inverse = FALSE, assignConstant = c("lower", "lower") )
x1 |
|
x2 |
|
model |
|
conditions |
|
param |
|
control |
|
interpolation |
|
inverse |
|
assignConstant |
|
Both x1
and x2
must be in the time range provided by conditions.
model
is a function defined by the user that return the rate at which time elapse in the new scale. It takes variables, model parameters (param
as a list
) and optional arguments (under a list
named control
). All arguments of the model that is not either param
or control
are considered variables; therefore, any number of variables and any name can be chosen, with the exception of the word time
). The model should accept numeric vectors of the same length as variable and return a value greater or equal to zero. Some models are already included in the package and can serve as template (modelGDD
, modelLinear
, modelBriere1999
).
conditions
is a data.frame
that contains one column named time
and other columns with the same name as the model variables. It represents the evolution of the model variable through time. Checks are made when calling timeScale
and timeShift
to ensure conditions
and the model
are compatible. Other checks are made on conditions
, including that time
must be a strictly increasing numeric
, but not necessarily of regular interval. Units of times must simply match the definition of the model, but day is a good choice. Conditions values are considered constant in time until the next measurement.
For the inverse option, a specified scaled time can be associated on an interval of time instead of a unique value, if the rate specified by the model is zero. The time (z1
and z2
) associated to x1
and x2
are calculated using timeShift
, values are calculated separately using the first and second element of assignConstant
.
Return a vector of the same length as x1
and x2
representing the scaled time (or time if inverse = TRUE
) elapsed between those values.
conditions <- data.frame(time = seq(0,30,length.out = 10), temp = rnorm(10, 25, 5)) model <- "modelLinear" param = list(a = 1, T0 = 10) x1 = rep(0,10) x2 = seq(11,20,length.out = 10) z2 <- timeScale(x1, x2, model = model, conditions = conditions, param = param) z1 <- rep(0,10,length.out = 10) timeScale(z1, z2, model = model, conditions = conditions, param = param, inverse = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.