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

Yohan Chalabi chalabi at phys.ethz.ch
Tue Oct 18 14:49:18 CEST 2011


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.
> 



More information about the R-SIG-Finance mailing list