[R] as.Date question

Linlin Yan yanlinlin82 at gmail.com
Thu Dec 24 18:00:40 CET 2009


I am afraid that although in same literally, they are indeed different
functions: as.Date.POSIXct and as.Date.POSIXlt. But I am not sure why
they are designed like this, which causes the confusion as you
mentioned.

On Thu, Dec 24, 2009 at 11:02 PM, MAL <diverses at univecom.ch> wrote:
> Mark, not sure that's the answer.
>
> Usually one has x=y --> f(x)=f(y)
>
> which doesn't seem to hold here (put x=zzz1, y=zzz2, f=as.Date()).
>
> Or do I overlook something?
>
>
> ----- Original Message ----- From: "Marek Janad" <marek.janad at gmail.com>
> To: <r-help at r-project.org>
> Sent: Thursday, December 24, 2009 00:08
> Subject: Re: [R] as.Date question
>
>
>> Look at documentation
>>
>> ?as.Date
>>
>> as.Date first represents time in UTC, what gives:
>>
>> as.POSIXlt(zzz1, tz="UTC")
>>
>> HTH
>>
>> 2009/12/20 MAL <diverses at univecom.ch>:
>>>
>>> All!
>>>
>>> This piece of code:
>>>
>>> zzz1 <- as.POSIXct("1999-03-18", tz="CET")
>>> zzz2 <- as.POSIXlt("1999-03-18", tz="CET")
>>> zzz1 == zzz2
>>> as.Date(zzz1)
>>> as.Date(zzz2)
>>>
>>> yields TRUE for "zzz1==zzz2", but the two dates returned by as.Date are
>>> different:
>>>
>>>> as.Date(zzz1)
>>>
>>> [1] "1999-03-17"
>>>>
>>>> as.Date(zzz2)
>>>
>>> [1] "1999-03-18"
>>>
>>> I'm using R 2.10.0.
>>>
>>> Would be glad for any clarifications. Thanks!
>>>
>>> ______________________________________________
>>> R-help at r-project.org 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.
>>>
>>
>>
>>
>> --
>> Marek
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>
> ______________________________________________
> R-help at r-project.org 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