[R] chron() question

javier garcia-pintado jgarcia at ija.csic.es
Mon Jun 18 20:03:05 CEST 2007


Hi all,
I'm using chron and it seems to me that there is a strange behaviour
when constructing chronological objects.
An extract of my source data is:

> tdr.hhmm[4860:4870]
 [1] "22:22:00" "22:42:00" "23:02:00" "23:22:00" "23:42:00" "00:02:00"
 [7] "00:22:00" "00:42:00" "01:02:00" "01:22:00" "01:42:00"
> tdr.dat$year[4860:4870]
 [1] 2005 2005 2005 2005 2005 2006 2006 2006 2006 2006 2006
> tdr.dat$day[4860:4870]
 [1] 365 365 365 365 365   1   1   1   1   1   1

And if I use:
> tdr.chron <- 
chron(dates.=tdr.dat$day,times.=tdr.hhmm,origin.=c(month=1,day=0,year=tdr.dat$year),format=c(dates="d/m/y",times="h:m:s"))
The result is:

> tdr.chron[4860:4870]
 [1] (31/12/05 22:22:00) (31/12/05 22:42:00) (31/12/05 23:02:00)
 [4] (31/12/05 23:22:00) (31/12/05 23:42:00) (01/01/05 00:02:00)
 [7] (01/01/05 00:22:00) (01/01/05 00:42:00) (01/01/05 01:02:00)
[10] (01/01/05 01:22:00) (01/01/05 01:42:00)

While it seems to me that, through the R recycling rule, it should
consider the year 2006 in the corresponding results. Isn't it so?

Wishes,
Javier

-- 
Javier García-Pintado
Institute of Earth Sciences Jaume Almera (CSIC)
Lluis Sole Sabaris s/n, 08028 Barcelona
Phone: +34 934095410
Fax:   +34 934110012
e-mail:jgarcia at ija.csic.es 



More information about the R-help mailing list