periodicity: Approximate Series Periodicity

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/periodicity.R

Description

Estimate the periodicity of a time-series-like object by calculating the median time between observations in days.

Usage

1

Arguments

x

time-series-like object

...

unused

Details

A simple wrapper to quickly estimate the periodicity of a given data. Returning an object of type periodicity.

This calculates the median number of days between observations as a difftime object, the numerical difference, the units of measurement, and the derived scale of the data as a string.

The time index currently must be of either Date or POSIX class, or coercible to such.

The only list item of note is the scale. This is an estimate of the periodicity of the data in common terms - e.g. 7 day dialy data is best described as ‘weekly’, and would be returned as such.

Possible scale values are:

‘minute’,‘hourly’, ‘daily’,‘weekly’, ‘monthly’,‘quarterly’, and ‘yearly’.

Value

An object containing a list containing the difftime object, frequency, units, and suitable scale.

Note

This function is only a good estimate for the underlying periodicity. If the series is too short, or has no real periodicity, the return values will obviously be wrong. That said, it is quite robust and used internally within xts.

Author(s)

Jeffrey A. Ryan

See Also

difftime

Examples

1
2
zoo.ts <- zoo(rnorm(231),as.Date(13514:13744,origin="1970-01-01"))
periodicity(zoo.ts)

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Daily periodicity from 2007-01-01 to 2007-08-19 

xts documentation built on Sept. 13, 2020, 5:09 p.m.