Re: [R] RE: problem with Dates

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Sat 19 Mar 2005 - 02:33:38 EST

On Fri, 18 Mar 2005, Benjamin Esterni wrote:

> It seems that you have load the "survival" package
> date.mdy is a function from this one.
> In this function the "origin" of the time is the first day of 1970
> in the base package the origin is the first day of 1960
> it's very curious...

Well, it would be very curious if they defined the same class, but the base package defines "Date" and the survival package defines "date". There's no reason why they should use the same origin, but it will cause problems if you mix them up.

         -thomas

> Benjamin Esterni
> France
>
> From: "Vegard Andersen" <vegard.andersen@ism.uit.no>
> Subject: [R] Date conversion problem using "as.Date"
> To: "r-help@lists.r-project.org" <r-help@stat.math.ethz.ch>
> Message-ID: <opsntv38wtk0a1dr@petter-smart>
> Content-Type: text/plain; format=flowed; delsp=yes;
> charset=iso-8859-15
>
> Hello!
>
> My problem is that the Julian date "behind" my dates seems to be wrong. I
> will examplify my problem.
>
> t1 <- "1998-11-20"
> t2 <- as.Date(t1)
> # Here t2 is correctly "1998-11-20", but
> date.mdy(t2)
> $month
> [1] 11
> $day
> [1] 19
> $year
> [1] 1988
>
> And indeed, if I write: fix(t2) then I get : structure(10550, class =
> "Date"). So the Julian date is 10550, which is "1988-11-19", not the
> correct "1998-11-20"
>
> If I instead of "as.Date" use "as.date", then things work ok. But I have
> not found out how to instruct "as.date" to handle dates from the 21st
> century.
>
>
> I hope that someone can help me, thanks in advance!
>
> --
> Best regards,
> Vegard Andersen
> Institute of Community Medicine
> University of Tromso
> Tromso, Norway
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle

______________________________________________
R-help@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 Received on Sat Mar 19 02:37:53 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:51 EST