time365 {cmrutils} | R Documentation |
Helper Time-Series Routines
Description
Converts beetween Date
objects and sampling times of
daily time series with the natural time period of 1 year.
Usage
time365toDate(x)
time365fromDate(x)
Arguments
x |
A vector of sampling times ( |
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
## 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")))
[Package cmrutils version 1.3.1 Index]