sdTemporalFunction: Transform Time Series Variables into Temporal Functions

Description Usage Arguments Details Value Examples

Description

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.

Usage

1
2
sdTemporalFunction(x, colTimes = 1, colValue = 2, method = "linear",
  sep = ",", dec = ".", header = TRUE, timeSeriesDirectory = "")

Arguments

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 x is a matrix, a data.frame or a text file name. The default value is 1.

colValue

(Optional) The number or name of the column that contains the time series values, when an element of x is a matrix, a data.frame or a text file name. The default value is 2.

method

Specifies the interpolation method to be used. Choices are: "linear" or "constant" for an approxfun function performing the interpolation; or, "fmm", "natural", "periodic", "monoH.FC" or "hyman" for a splinefun function performing the interpolation.

sep

The field separator character used in the data files, when x is a file name. Default is ",".

dec

The decimal point character used in the data files, when x is a file name. Default is ".".

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 read.table function. Default is TRUE.

timeSeriesDirectory

The path to the directory where the time series data files are stored, when x is a character file name.

Details

Uses the approxfun or the splinefun function to interpolate the time series values across the given time sequence.

What happens when x is a:

Value

A function performing the linear, constant or spline interpolation of the time series points or NULL if an error occurs.

Examples

 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

EmbrapaInformaticaAgropecuaria/sdsim documentation built on May 10, 2019, 9:58 a.m.