[datatable-help] Import problem with data.table in packages

Ken Williams Ken.Williams at windlogics.com
Mon May 6 23:26:49 CEST 2013



> -----Original Message-----
> From: Matthew Dowle [mailto:mdowle at mdowle.plus.com]
> Sent: Wednesday, May 01, 2013 4:13 PM
> To: Ken Williams
> Cc: datatable-help at lists.r-forge.r-project.org
> Subject: Re: [datatable-help] Import problem with data.table in packages
>
>
> Hi,
>
> This rings a bell actually. data.table uses .onLoad currently but it should be
> using .onAttach, I seem to recall.
>
>
> http://r.789695.n4.nabble.com/Error-in-a-package-that-imports-data-table-
> tp4660173p4660637.html
>
> I had a hunt around but couldn't find if we decided data.table should move
> from .onLoad to .onAttach.  Does anyone know/remember?

I'm not sure - but maybe a solution would be to explicitly prefix the package name:

Index: pkg/R/onLoad.R
===================================================================
--- pkg/R/onLoad.R      (revision 855)
+++ pkg/R/onLoad.R      (working copy)
@@ -6,7 +6,7 @@
     if (class(ss)!="{") ss = as.call(c(as.name("{"), ss))
     if (!length(grep("data.table",ss[[2]]))) {
         ss = ss[c(1,NA,2:length(ss))]
-        ss[[2]] = parse(text="if (inherits(..1,'data.table')) return(data.table(...,key=key(..1)))")[[1]]
+        ss[[2]] = parse(text="if (inherits(..1,'data.table')) return(data.table::data.table(...,key=key(..1)))")[[1]]
         body(tt)=ss
         (unlockBinding)("cbind.data.frame",baseenv())
         assign("cbind.data.frame",tt,envir=asNamespace("base"),inherits=FALSE)
@@ -17,7 +17,7 @@
     if (class(ss)!="{") ss = as.call(c(as.name("{"), ss))
     if (!length(grep("data.table",ss[[2]]))) {
         ss = ss[c(1,NA,2:length(ss))]
-        ss[[2]] = parse(text="if (inherits(..1,'data.table')) return(`.rbind.data.table`(...))")[[1]]
+        ss[[2]] = parse(text="if (inherits(..1,'data.table')) return(`data.table::.rbind.data.table`(...))")[[1]]
         body(tt)=ss
         (unlockBinding)("rbind.data.frame",baseenv())
         assign("rbind.data.frame",tt,envir=asNamespace("base"),inherits=FALSE)


________________________________

CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.


More information about the datatable-help mailing list