frequency function

Frequency of a Time Series

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. Therefore, these functions have been extended.

## S3 method for class 'xts' frequency(x,...)

Arguments

  • x: Input time series.
  • ...: Backward compatibility.

Returns

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 day-saving and bissextile years.

See Also

normalizeYP

NUMPERIOD

BIMETS indexing

Examples

#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)
  • Maintainer: Andrea Luciani
  • License: GPL-3
  • Last published: 2024-11-25