[R] chron blues

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Jan 2 15:46:34 CET 2001


Bernie McConnell <bm8 at st-andrews.ac.uk> writes:

> GoodDay,
> 
> Could someone please tell me why b (below) does not return a vector of 10
> chron objects?  Hopefuly I am being remarkably naive or have missed
> something obvious in the chron documentation.  I'm running Win NT 4.0

I don't think you're particularly naive...
The root of this seems to be this

Browse[1]> unclass(e1)+c(1.5,1.5)
[1] 3658.5 3658.5
Browse[1]> unclass(e1)+c(1.5)
[1] 3658.5
attr(,"format")
[1] "d/m/y" "h:m:s"
attr(,"origin")
month   day  year 
    1     1  1970 


This is a generic issue, recycling kills attributes:

> x<-1
> attr(x,"foo")<-"bar"
> x+1
[1] 2
attr(,"foo")
[1] "bar"
> x+1:2
[1] 2 3

I forget whether there's a logic to this, but S-Plus 3.4 is doing the
same thing. Hence, Ops.dates inside chron probably needs fixing.
Specifically at the line

   val <- NextMethod(.Generic)

(original problem:)

> > library(chron)
> > gps.start.date <<- chron("06/01/80",
> +                         "00:00:00",  
> +                         format=c("d/m/y","h:m:s"))
..
> <bold>> b <<- gps.start.date + rep(1.5,10)


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list