Frequency of a Time Series
This function returns the frequency of a time series. In the case of a sparse xts()
time series, and in other cases, the R functions xts::periodicity()
and frequency()
do not return BIMETS compliant values. We suggest to use this function when a BIMETS time series frequency is requested.
## S3 method for class 'xts' frequency(x,...)
x |
Input time series. |
... |
Backward compatibility. |
This function returns the integer value stored in the attribute .bimetsFreq
of the input time series, if any. Otherwise the frequency will be calculated by using the shortest time difference between two observations, while accounting for daysaving and bissextile years.
#build a sparse xts() xArr=rnorm(13) dateArr=seq(as.Date('2000/01/01'),by='6 months',length=10) dateArr2=seq(as.Date('2010/01/01'),by='3 months',length=3) #strange array of dates here below... dateArr3=c(dateArr,dateArr2) dataF=data.frame(dateArr3,xArr) xt=xts(dataF[,2],order.by=dataF[,1]) #get bimets calculated frequency cat(frequency(xt)) #print 4... without bimets R returns 1 #...legacy periodicity() periodicity(xt)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.