Hi,
I've got a small test package constructed like so:
------------ R/MyCode.R: ---------------
##' Example function.
##'
##' @export
##' @import data.table
myfunc <- function() {
dt1 <- data.table(time=1:5, key='time')
dt2 <- data.table(time=3:8, key='time')
dat <- merge(dt1, dt2, all=TRUE)
}
------------ DESCRIPTION: ---------------
Package: TestMod
Type: Package
Title: My test package
Version: 1.0
Author: Ken Williams <[email protected]>
Maintainer: Ken Williams <[email protected]>
Description: A test package
License: BSD
Imports:
data.table
Collate:
'MyCode.R'
-----------------------------------------------
I process the package with ROxygen in RStudio, which produces an empty `inst/`
directory, some docs in `man/`, and a `NAMESPACE` file:
------------ DESCRIPTION: ---------------
export(myfunc)
import(data.table)
-----------------------------------------------
Now, if I start a fresh R session and load this package, I get a namespace
error:
------------ R 2.15.2 session: ---------------
> library(TestMod)
> myfunc
function ()
{
dt1 <- data.table(time = 1:5, key = "time")
dt2 <- data.table(time = 3:8, key = "time")
dat <- merge(dt1, dt2, all = TRUE)
}
<environment: namespace:TestMod>
> myfunc()
Error in rbind(deparse.level, ...) :
could not find function ".rbind.data.table"
-----------------------------------------------
Sometimes, in other (more complicated) code, I instead get the error 'could not
find function "data.table"'.
To my eyes, the imports look correct, so I can't see what the problem is:
------------ R 2.15.2 session: ---------------
> getNamespaceImports('TestMod')$data.table
%between% %chin% %like% .__C__data.table
"%between%" "%chin%" "%like%" ".__C__data.table"
.__C__IDate .__C__ITime .__T__$:base .__T__$<-:base
".__C__IDate" ".__C__ITime" ".__T__$:base" ".__T__$<-:base"
.__T__[:base .rbind.data.table := alloc.col
".__T__[:base" ".rbind.data.table" ":=" "alloc.col"
as.chron.IDate as.chron.ITime as.data.table as.IDate
"as.chron.IDate" "as.chron.ITime" "as.data.table" "as.IDate"
as.ITime between chgroup chmatch
"as.ITime" "between" "chgroup" "chmatch"
chorder CJ copy data.table
"chorder" "CJ" "copy" "data.table"
fread haskey hour IDateTime
"fread" "haskey" "hour" "IDateTime"
is.data.table key key<- last
"is.data.table" "key" "key<-" "last"
like mday month quarter
"like" "mday" "month" "quarter"
rbindlist set setattr setcolorder
"rbindlist" "set" "setattr" "setcolorder"
setkey setkeyv setnames SJ
"setkey" "setkeyv" "setnames" "SJ"
tables test.data.table timetaken truelength
"tables" "test.data.table" "timetaken" "truelength"
wday week yday year
"wday" "week" "yday" "year"
-----------------------------------------------
Any suggestions?
I think for now, I can work around the problem by doing 'Depends: data.table'
in my `DESCRIPTION` file. I'd like to not do that though.
--
Ken Williams, Senior Research Scientist
WindLogics
http://windlogics.com
________________________________
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.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help