Retrieve Dates of Time Series
This function returns the dates array of selected observations, in the requested print format. Dates will be provided accordingly to the BIMETS configuration option BIMETS_CONF_DIP
(see BIMETS configuration )
GETDATE(x=NULL, index=NULL, format='%Y-%m-%d', avoidCompliance=FALSE, ...)
x |
Input time series that must satisfy the compliance control check defined in |
index |
Index of observations to be selected. The output dates will be the dates of the selected observations. If |
format |
Output print format, provided as a paste of the following codes: |
avoidCompliance |
If |
... |
Backward compatibility. |
This function returns the dates array of selected observations, in the requested print format.
#day and month names can change depending on locale
Sys.setlocale('LC_ALL','C')
Sys.setlocale('LC_TIME','C')
#work on xts
setBIMETSconf('BIMETS_CONF_CCT','XTS')
#XTS yearly
n=10
xArr=(n:1)
dateArr=seq(as.Date('2000-12-31'),by='year',length=n)
dataF=data.frame(dateArr,xArr)
ts1=xts(dataF[,2],order.by=dataF[,1])
ts1[5]=NA
print(GETDATE(ts1,5)) #...print 2004-12-31
print(GETDATE(ts1,5,'%A %d %b %Y')) #print... Friday 31 Dec 2004
print(GETDATE(ts1)) #print... "2000-12-31" "2001-12-31" ... "2009-12-31"
#XTS quarterly
n=15
xArr=(n:0)
dateArr=as.yearqtr('2000 Q1')+0:n/4
dataF=data.frame(dateArr,xArr)
ts1=xts(dataF[,2],order.by=dataF[,1])
print(GETDATE(ts1,9,'%b %Y')) #print...Mar 2002
#XTS monthly
#set configuration BIMETS_CONF_DIP to FIRST
setBIMETSconf('BIMETS_CONF_DIP','FIRST')
n=15
xArr=(n:0)
dateArr=as.yearmon('Jan 2000')+0:n/12
dataF=data.frame(dateArr,xArr)
ts1=xts(dataF[,2],order.by=dataF[,1])
print(GETDATE(ts1,9,'%b %Y')) #print...Sep 2000
#set configuration BIMETS_CONF_DIP to LAST
setBIMETSconf('BIMETS_CONF_DIP','LAST')
#2000 is bissextile...
print(GETDATE(ts1,2)) #print... 2000-02-29
#quarter...
print(GETDATE(ts1,5,'%Y Q%q')) #print... 2000 Q2
#restore default
setBIMETSconf('BIMETS_CONF_CCT','TS')Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.