[datatable-help] Error in a package that imports data.table

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Mar 7 05:09:29 CET 2013


Hi,

On Wed, Mar 6, 2013 at 10:47 PM, Victor Kryukov
<victor.kryukov at gmail.com> wrote:
[snip]
> I'm puzzled about why data table would include this function/classes (isn't
> it better to leave data handling to specialized classes?), but I understand
> that there may be a good reason for that.

I became a data.table user after IDateTime was in there (and I don't
ever use it, actually), but my *guess* would be that it's there to use
dates as keys for data.table ...

> Unfortunately, my code is using
> lubridate heavily (it's just too good...), which leaves me in a tough spot -
> I would like to use both. If I had to choose, I would be forced to replace
> all lubridate code with standard R, which is not fun, but I guess I have to
> bite the bullet.

You don't have to choose one over the other.

I suspect import order could do the trick. Perhaps import()-ing
data.table first, then lubridate might be all you have to do.

If not, I *think* if you define hour, mday, mont, etc. in your package code as:

mday <- lubridate::mday
hour <- lubridate::hour

And ensure that those functions are loaded first (either by using
Collate: and specifying that file first, or putting that in a function
called aaa.R or something), perhaps your code will recover "just like
that"

If that doesn't work either, another option is that  you just prefix
every lubridate call in your package code with the lubridate package
name, eg. instead of `year(whenever)` you do
`lubridate::year(whenever)`.

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


More information about the datatable-help mailing list