TSERIES {bimets} | R Documentation |
Create a Time Series
Description
This function returns a time series that is compliant with BIMETS compliance control defined in is.bimets
. Users can provide observation values, frequency, and the starting period. Moreover, users can provide metadata information that will be stored into the time series object as attributes.
TIMESERIES
is an alias for TSERIES
.
Usage
TIMESERIES(..., START = c(2000,1), FREQ = 1,
SOURCE = NULL, TITLE = NULL, UNITS = NULL, SCALEFAC = 0,
class=NULL, avoidCompliance = FALSE)
TSERIES(..., START = c(2000,1), FREQ = 1,
SOURCE = NULL, TITLE = NULL, UNITS = NULL, SCALEFAC = 0,
class=NULL, avoidCompliance = FALSE)
Arguments
... |
List of values to be inserted into the output time series. This function accepts
arguments of class |
START |
This argument defines the start of the time series. Starting period can be specified as |
FREQ |
The frequency of the time series. Frequency can be |
SOURCE |
Set the metadata string that represents the source of the data. Metadata will be lost if the current time series is transformed by any function that changes its values. |
TITLE |
Set the metadata string that represents the description of the data. Metadata will be lost if the current time series is transformed by any function that changes its values. |
UNITS |
Set the metadata string that represents the unit of measure of the data. Metadata will be lost if the current time series is transformed by any function that changes its values. |
SCALEFAC |
Set the numerical value that represents the scale factor of the data. Users may eventually want to use this value in code. Metadata will be lost if the current time series is transformed by any function that changes its values. |
class |
If Please note that BIMETS package performs better with |
avoidCompliance |
If |
Value
This function returns a BIMETS time series that is compliant with the BIMETS compliance control defined in is.bimets
.
See Also
is.bimets
as.bimets
BIMETS indexing
BIMETS configuration
fromBIMETStoTS
fromBIMETStoXTS
NOELS
TSDATES
INTS
TABIT
Examples
#day and month names can change depending on locale
Sys.setlocale('LC_ALL','C')
Sys.setlocale('LC_TIME','C')
#create a simple R ts
n<-10
ts1<-ts((1:n),start=c(2000,1),frequency=1)
#create a bimets ts annual
#having the following values: 5, (all data in ts1), NA, 8
#starting from Jan 2020, and having custom metadata
out_tseries<-TIMESERIES(5,ts1,NA,8,START=c(2020,1),FREQ=1,
SOURCE='mySource',TITLE='myTitle',UNITS='myUnits',SCALEFAC=2)
#print out
TABIT(out_tseries)
#use Date() as start date
TABIT(TIMESERIES(1:10,START=as.Date('2000-01-01'),FREQ='A'))
TABIT(TIMESERIES(1:10,START=as.Date('2000-01-01'),FREQ='Y'))
TABIT(TIMESERIES(1:10,START=as.Date('2000-07-08'),FREQ='D'))
TABIT(TIMESERIES(1:10,START=as.Date('2018-01-01'),FREQ='W'))
#use yearmon()/yearqtr() as start date
TABIT(TIMESERIES(1:10,START=as.yearmon('Mar 2001'),FREQ='M'))
TABIT(TIMESERIES(1:10,START=as.yearqtr('2000 Q3'),FREQ='Q'))
#create ts monthly with metadata
out_tseries<-TIMESERIES(5,ts1,NA,8,START=c(2020,1),FREQ='M',
SOURCE='mySource',TITLE='myTitle',UNITS='myUnits',SCALEFAC=2)
#print out
TABIT(out_tseries)
#create daily
out_tseries<-TSERIES(5,ts1,NA,8,START=c(2000,1),FREQ=366,
SOURCE='mySource',TITLE='myTitle',UNITS='myUnits',SCALEFAC=2)
#print out
TABIT(out_tseries)
#insert values skipping 366 in non-bissextile
myLength<-400
myValues<-1:myLength
myDates<-as.Date('2001-01-01')+0:(myLength-1)
ts<-as.bimets(xts(myValues,order.by = myDates))
TABIT(ts) #366 observation will be a duplicated of 365, see as.bimets() help