Learn R Programming

greybox (version 2.0.2)

detectdst: DST and Leap year detector functions

Description

Functions to detect, when Daylight Saving Time and leap year start and finish

Usage

detectdst(object)

detectleap(object)

Value

List containing:

  • start - data frame with id (number of observation) and the respective dates, when the DST / leap year start;

  • end - data frame with id and dates, when DST / leap year end.

Arguments

object

Either a zoo / xts object or a vector of dates / times in POSIXt / Date class. Note that in order for detectdst() to work correctly, your data should not have missing observations. Otherwise it might not be possible to locate, when DST happens.

Author

Ivan Svetunkov, ivan@svetunkov.ru

Details

The detectdst function detects, when the change for the DST starts and ends. It assumes that the frequency of data is not lower than hourly. The detectleap function does similar for the leap year, but flagging the 29th of February as a starting and to the 28th of February next year as the ending dates.

In order for the methods to work, the object needs to be of either zoo / xts or POSIXt class and should contain valid dates.

See Also

xregExpander, temporaldummy, outlierdummy

Examples

Run this code
# Generate matrix with monthly dummies for a zoo object
x <- as.POSIXct("2004-01-01")+0:(365*24*8)*60*60
detectdst(x)
detectleap(x)

Run the code above in your browser using DataLab