Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

frequency

Frequency of a Time Series


Description

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.

Usage

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

Arguments

x

Input time series.

...

Backward compatibility.

Value

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.

See Also

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)

bimets

Time Series and Econometric Modeling

v1.5.3
GPL-3
Authors
Andrea Luciani [aut, cre], Roberto Stok [aut], Bank of Italy [cph]
Initial release
2021-02-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.