[R] time serie generation

Gabor Grothendieck ggrothendieck at gmail.com
Fri Jun 1 13:36:52 CEST 2007


library(chron)
dt1 <- chron("1/1/2002", "00:00:00")
dt2 <- chron("1/2/2002", "00:00:00")
chron(seq(as.numeric(dt1), as.numeric(dt2), by = 1/24))

Also (but see caveat in R News 4/1 help desk article):

dt1 <- as.POSIXct("2002-01-01 00:00:00")
dt2 <- as.POSIXct("2002-01-02 00:00:00")
seq(dt1, dt2, by = "hour")



On 6/1/07, jessica.gervais at tudor.lu <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.
>
> 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