[R-sig-finance] Date calculations

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Wed Mar 22 13:18:45 CET 2006


On Wed, 22 Mar 2006 00:38:20 -0600 P. Hénaff wrote:

> I'm a rank beginner in R and R-metrics, but experienced in matlab and
> other languages. I'm strugling with date arithmetics in R. I'm doing
> statistical analysis on financial time series, using its, which uses
> POSIXct objects to measure time. What is the best way to perform
> simple date arithmetic with these objects? I do not care about h/m/s,
> nor do I care about daylight saving time.

In that case I would recommend to go with the "Date" class available in
base R, e.g.
  as.Date("2005-04-03") + 0:10
which should be rather self-explanatory.

The package zoo provides time series infrastructure where the time
information can be stored in "Date" (or virtually any other class).
  library("zoo")
  z <- zoo(rnorm(11), as.Date("2005-04-03") + 0:10)
  plot(z)

hth,
Z



More information about the R-sig-finance mailing list