[datatable-help] Error: no method or default for coercing "character" to "IDate"

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Jul 27 17:23:22 CEST 2011


Hi Chris,

FYI, I just checked this a minute ago, so you'll automatically get
this in the next release.

In the meantime, I'd be much obliged if you us know if the "bandaid"
version I suggested, ie. adding:

setOldClass("IDate")
setOldClass("ITime")
setAs("character", "IDate", function(from) as.IDate(from))
setAs("character", "ITime", function(from) as.ITime(from))

to your workspace allows you to successfully set the colClasses values
in your read.* function calls.

Thanks,
-steve


On Wed, Jul 27, 2011 at 11:10 AM, Steve Lianoglou
<mailinglist.honeypot at gmail.com> wrote:
> Hi,
>
> On Wed, Jul 27, 2011 at 10:20 AM, Chris Neff <caneff at gmail.com> wrote:
>> Hi all,
>> Using read.csv's colClasses argument with a date column tagged as IDate
>> doesn't work. Distilling it down it is the following.
>> This works:
>> as.IDate("2010/11/01")
>> but this doesn't (and is what read.csv uses):
>> as("2010/11/01","IDate")
>>
>> I'm not familiar enough with the class semantics any more to remember, but
>> any reason why this isn't doable?
>
> This is definitely doable.
>
> Matthew has been making several updates to data.table, and I think
> wants to release another version soon (no ETA on that from me,
> though).
>
> We can get that into the codebase before the next release, for sure.
>
> The additions are simple, though, so if you can't wait for that, you
> can drop these few lines somewhere in your codebase and have it loaded
> into your R workspace. It should enable the functionality you need:
>
> setOldClass("IDate")
> setOldClass("ITime")
>
> setAs("character", "IDate", function(from) as.IDate(from))
> setAs("character", "ITime", function(from) as.ITime(from))
>
> With that "loaded up", you can then do:
>
> R> as("2011-01-01", "IDate")
> [1] "2011-01-01"
>
> HTH,
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
>  | Memorial Sloan-Kettering Cancer Center
>  | Weill Medical College of Cornell University
> Contact Info: http://cbio.mskcc.org/~lianos/contact
>



-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


More information about the datatable-help mailing list