[R] time serie generation

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Jun 1 14:02:53 CEST 2007


On Fri, 1 Jun 2007 12:51:35 +0200 jessica.gervais at tudor.lu wrote:

> 
> Dear all,
> 
> I would like to generate a regular time serie, i.e. a list of dates
> and time for each our of the period 2002-2004.

use the seq() method for "POSIXct" objects:

seq(from = as.POSIXct("2002-01-01 00:00:00"),
    to = as.POSIXct("2004-12-31 23:00:00"),
    by = "hour")

hth,
Z

> the time format should be
> "2002-01-01 12:00:00" (year-month-day hour:min:sec)
> 
> 
> so the list should contain all hours of the period 2002-2004
> 2002-01-01 00:00:00
> 2002-01-01 01:00:00
> 2002-01-01 02:00:00
> ...
> 2004-12-31 23:00:00
> Does a function exist to create that kind of list ?
> 
> Thanks in advance,
> 
> 
> Jessica
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.
>



More information about the R-help mailing list