Convert TS to XTS
This function transforms a BIMETS compliant ts
time series (as defined in is.bimets
) into a time series of class xts()
.
The core XTS function as.xts()
does not satisfy all the requirements of the compliance control check, so it has been extended. If the output time series has an .indexClass
of type Date()
, i.e. neither monthly nor quarterly, the output dates are chosen accordingly to the BIMETS option BIMETS_CONF_DIP
: if this option is set to LAST
(default), the output xts()
time series will have the date of the period set equal to the last day in the same period, e.g. 31 December for yearly time series, 30 June for semiannual, etc.; if BIMETS option BIMETS_CONF_DIP
is set to FIRST
, the output xts()
time series will have the date of the period set equal to the first day in the same period, e.g. 1 January for yearly time series, 1 July for semiannual time series on the second period, etc.
In the case of quarterly time series the .indexClass=yearqtr
;
in the case of monthly time series the .indexClass=yearmon
.
Attributes and description of the input time series will be copied to the output time series (see TIMESERIES
)
fromTStoXTS(x = NULL, avoidCompliance = FALSE, ...)
This function returns a time series of class xts()
that has the same observations of the input ts
time series.
#day and month names can change depending on locale Sys.setlocale('LC_ALL','C') Sys.setlocale('LC_TIME','C') #BIMETS_CONF_DIP default on LAST print('yearly') t=ts(1:20,start=c(2005,2),frequency=1) ts=fromTStoXTS(t) print(t);print(ts) #...dates on 31 Dec print('semiannual') t=ts(1:20,start=c(2005,2),frequency=2) ts=fromTStoXTS(t) print(t);print(ts) #...dates on 31 Dec/30 Jun #set configuration BIMETS_CONF_DIP on FIRST setBIMETSconf('BIMETS_CONF_DIP','FIRST') print('yearly') t=ts(1:20,start=c(2005,2),frequency=1) ts=fromTStoXTS(t) print(t);print(ts) #...dates on 1 Jan print('semiannual') t=ts(1:20,start=c(2005,2),frequency=2) ts=fromTStoXTS(t) print(t);print(ts) #...dates on 1 Jan/1 Jul print('quarterly') t=ts(1:20,start=c(2004,3),frequency=4) ts=fromTStoXTS(t) print(t);print(ts) print('monthly') t=ts(1:20,start=c(2003,5),frequency=12) ts=fromTStoXTS(t) print(t);print(ts) print('daily') t=ts(1:20,start=c(2003,125),frequency=366) ts=fromTStoXTS(t) print(t);print(ts)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.