[R-SIG-Finance] issues with zoo masking as.Date function, resulting in issues with as.Date

Zhang, Ivan ivan.zhang at bankofamerica.com
Tue Oct 18 14:53:58 CEST 2011


Thanks for the tip and workaround, this sounds like a bug with zoo package.

-Ivan

-----Original Message-----
From: Yohan Chalabi [mailto:chalabi at phys.ethz.ch] 
Sent: Tuesday, October 18, 2011 8:49 AM
To: Gabor Grothendieck
Cc: Zhang, Ivan; r-sig-finance
Subject: Re: [R-SIG-Finance] issues with zoo masking as.Date function, resulting in issues with as.Date


On 14 oct. 2011, at 20:19, Gabor Grothendieck wrote:

> On Fri, Oct 14, 2011 at 1:21 PM, Zhang, Ivan 
> <ivan.zhang at bankofamerica.com> wrote:
>> Hi Everyone,
>> 
>> I just upgraded to 2.13, this seems like a very obvious issue however I haven't seen this addressed anywhere, perhaps I am missing something elementary?
>> 
>> library(timeDate)
>>> as.Date(timeDate('2011-10-10'))
>> [1] "2011-10-10"
>>> library(zoo)
>> 
>> Attaching package: 'zoo'
>> 
>> The following object(s) are masked from 'package:base':
>> 
>>    as.Date
>> 
>>> as.Date(timeDate('2011-10-10'))
>> Error in as.Date.default(timeDate("2011-10-10")) :
>>  do not know how to convert 'timeDate("2011-10-10")' to class "Date"
>>> 
>> 
> 
> The timeDate package needs to export as.Date.timeDate in its NAMESPACE

?? timeDate does export as.Date.timeDate as an S3 method.

If the zoo package overwrites a base function and do not import namespaces of other packages which extend it. It cannot work.

in this particular example

base::as.Date(timeDate('2011-10-10'))

works.

> file .   As a workaround you can do this:
> 
>> as.Date.timeDate <- timeDate:::as.Date.timeDate
>> as.Date(timeDate('2011-10-10'))
> [1] "2011-10-10"
> 
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
> 
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
> 

----------------------------------------------------------------------
This message w/attachments (message) is intended solely ...{{dropped:7}}



More information about the R-SIG-Finance mailing list