time356: Helper Time-Series Routines

Description Usage Arguments Details Value See Also Examples

Description

Converts beetween Date objects and sampling times of daily time series with the natural time period of 1 year.

Usage

1
2

Arguments

x

A vector of sampling times (time365toDate) or dates (time365fromDate).

Details

A simple approach to modelling daily time series with the natural time period of 1 year is to use ts object with \code{frequency} = 365, that is to assume no leap days.

time365fromDate returns NA for the leap day February 29.

Value

A vector of dates (time365fromDate) or sampling times (time365toDate).

See Also

time.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  ## non-leap year
  x <- ts(1:4, start = c(1991, 58), frequency = 365)
  time365toDate(time(x))
  d <- seq.Date(as.Date('1991-02-27'), as.Date('1991-03-02'), 1)
  time365fromDate(d)

  ## leap year
  x <- ts(1:4, start = c(1992, 58), frequency = 365)
  time365toDate(time(x))
  d <- seq.Date(as.Date('1992-02-27'), as.Date('1992-03-02'), 1)
  time365fromDate(d)

  x <- seq(1900, 2100, by = 1/365)
  stopifnot(all(abs(x - time365fromDate(time365toDate(x))) <
                getOption("ts.eps")))

aparamon/cmrutils documentation built on May 5, 2019, 6:54 p.m.