The function `tsconvert` is used to convert any one-dimensional vector/list into a time-series objects.
tsconvert(x, t, frequency = NULL, format = NULL, x.name = NULL)x is returned as a `ts` object with the attributes `tsp` (start, end, and frequency of x), `series.name` (series name, optional), and `seasonal.cycle` (time gap between series observations).
a univariate time series object or a numeric vector or matrix.
a vector or list of time in which the series values were observed.
the number of observations per unit of time. If omitted, R will identify the frequency based on the time vector specified in t. Default is NULL.
time format specified for the variable provided in t. If omitted, R will identify this automatically. Default is NULL.
name of the series. If omitted here, the series name found by tsname() will be taken over here. If tsname() is NULL, the variable name will be used instead. Default is NULL.
Ka Yui Karl Wu
The function tsconvert is used to convert vectors/lists into time-series objects. These are vectors or matrices which inherit from class "ts" (and have additional attributes) and represent data sampled at equispaced points in time. Time series must have at least one observation, and although they need not be numeric there is very limited support for non-numeric series.
Argument frequency indicates the sampling frequency of the time series, with the default value 1 indicating one sample in each unit time interval. For example, one could use a value of 7 for frequency when the data are sampled daily, and the natural time period is a week, or 12 when the data are sampled monthly and the natural time period is a year. Values of 4 and 12 are assumed in (e.g.) print methods to imply a quarterly and monthly series respectively. Note that frequency does not need to be a whole number: for example, frequency = 0.2 would imply sampling once every five time units.
travellers <- tsconvert(x = airport$Travellers, t = airport$Date)
Run the code above in your browser using DataLab