Description Usage Arguments Details Value Examples
The time series variables are the model variables that vary over time, e.g.
a diet that change after a period of time, meteorological data, etc. This
function helps to transform this kind of input variables into temporal
functions and it is automatically used by the sdScenarioClass
.
It accepts as inputs fixed values, matrices, data.frames or
text file names, and returns a function performing the linear, constant or
spline interpolation with extrapolation outside of the time interval.
See details for more informations about the accepted
types.
1 2 | sdTemporalFunction(x, colTimes = 1, colValue = 2, method = "linear",
sep = ",", dec = ".", header = TRUE, timeSeriesDirectory = "")
|
x |
The time series variable value. It can be a fixed value, a matrix, a data.frame or a character string with a file name. See details for more information. |
colTimes |
(Optional) The number or name of the column that contains the
time sequence, when an element of |
colValue |
(Optional) The number or name of the column that contains the
time series values, when an element of |
method |
Specifies the interpolation method to be used. Choices are:
"linear" or "constant" for an |
sep |
The field separator character used in the data files, when
|
dec |
The decimal point character used in the data files, when |
header |
a logical value indicating whether the file contains the names
of the variables as its first line. If missing, the value is determined from
the file format: header is set to TRUE if and only if the first row contains
one fewer field than the number of columns. To be passed to the
|
timeSeriesDirectory |
The path to the directory where the time series
data files are stored, when |
Uses the approxfun
or the splinefun
function to interpolate the time series values across the given time
sequence.
What happens when x
is a:
fixed value: The fixed value is repeated for any time step.
matrix or data.frame: The column colTimes
(default is 1)
should contain the time sequence and the column colValues
(default
is 2) should contain the values for each given time. Both columns are
numeric.
character: It is interpreted as a text file name. This file must
be inside the current working directory or inside the
timeSeriesDirectory
. The file should have 2 columns, the column
colTimes
(default is 1) should contain the time sequence and the
column colValues
(default is 2) should contain the values for each
given time. Both columns are numeric.
A function performing the linear, constant or spline interpolation of
the time series points or NULL
if an error occurs.
1 2 3 4 5 6 7 8 9 10 | # Diet in a data.frame with constant interpolation
diet <- data.frame(time = c(0,5,10), value = c(10,50,100))
dietFun <- sdTemporalFunction(x = diet, method = "constant")
dietFun(2)
#> [1] 10
dietFun(7)
#> [1] 50
dietFun(10)
#> [1] 100
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.