s-news
[Top] [All Lists]

S4 class timeDate

To: s-news <s-news@lists.biostat.wustl.edu>
Subject: S4 class timeDate
From: Frank E Harrell Jr <fharrell@virginia.edu>
Date: Mon, 23 Jun 2003 10:53:33 -0400
Organization: University of Virginia
How does one get the following to work properly in S-Plus 6?

> x <- timeDate(julian=0:10)
> x
 [1] 01/01/1960 01/02/1960 01/03/1960 01/04/1960 01/05/1960 01/06/1960
 [7] 01/07/1960 01/08/1960 01/09/1960 01/10/1960 01/11/1960
> c(x,x)
[[1]]:
[[1]][[1]]:
 [1]  0  1  2  3  4  5  6  7  8  9 10

[[1]][[2]]:
 [1] 0 0 0 0 0 0 0 0 0 0 0


[[2]]:
[1] "julian.day"   "milliseconds"

[[3]]:
[1] "integer" "integer"

[[4]]:
[1] "%02m/%02d/%Y"

. . .

POSIX date/times in R, which use S3 methods, do not have this problem:

> x <- ISOdate(year=1960,month=1,day=1:10)
> x
 [1] "1960-01-01 07:00:00 EST" "1960-01-02 07:00:00 EST"
 [3] "1960-01-03 07:00:00 EST" "1960-01-04 07:00:00 EST"
 [5] "1960-01-05 07:00:00 EST" "1960-01-06 07:00:00 EST"
 [7] "1960-01-07 07:00:00 EST" "1960-01-08 07:00:00 EST"
 [9] "1960-01-09 07:00:00 EST" "1960-01-10 07:00:00 EST"
> c(x,x)
 [1] "1960-01-01 07:00:00 EST" "1960-01-02 07:00:00 EST"
 [3] "1960-01-03 07:00:00 EST" "1960-01-04 07:00:00 EST"
 [5] "1960-01-05 07:00:00 EST" "1960-01-06 07:00:00 EST"
 [7] "1960-01-07 07:00:00 EST" "1960-01-08 07:00:00 EST"
 [9] "1960-01-09 07:00:00 EST" "1960-01-10 07:00:00 EST"
[11] "1960-01-01 07:00:00 EST" "1960-01-02 07:00:00 EST"
[13] "1960-01-03 07:00:00 EST" "1960-01-04 07:00:00 EST"
[15] "1960-01-05 07:00:00 EST" "1960-01-06 07:00:00 EST"
[17] "1960-01-07 07:00:00 EST" "1960-01-08 07:00:00 EST"
[19] "1960-01-09 07:00:00 EST" "1960-01-10 07:00:00 EST"

Neither do chron objects in S-Plus 6, which also use S3 methods:

> x <- chron(0:10)
> x
 [1] 01/01/60 01/02/60 01/03/60 01/04/60 01/05/60 01/06/60 01/07/60 01/08/60
 [9] 01/09/60 01/10/60 01/11/60
> c(x,x)
 [1] 01/01/60 01/02/60 01/03/60 01/04/60 01/05/60 01/06/60 01/07/60 01/08/60
 [9] 01/09/60 01/10/60 01/11/60 01/01/60 01/02/60 01/03/60 01/04/60 01/05/60
[17] 01/06/60 01/07/60 01/08/60 01/09/60 01/10/60 01/11/60

---
Frank E Harrell Jr              Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat

<Prev in Thread] Current Thread [Next in Thread>