You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Submitted by: K Davis; Assigned to: Arun ; R-Forge link
I create a test package with the following setup
NAMESPACE:
import(data.table)
export("testFunction")
DESCRIPTION:
Package: testPackage
Type: Package
Title: What the package does (short line)
Version:1.0Date:2014-03-31Author: Who wrote it
Maintainer: Who to complain to <[email protected]>
Description: More about what it does (maybe more than one line)
License: GPL (>= 2)
Imports:data.table (>= 1.9.3)
For the full package see the attached tar.gz. I build the package, install it, and then use it as follows:
# R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
# Platform: x86_64-pc-linux-gnu (64-bit)
library(testPackage)
testFunction()
# Error in do.call("CJ", list(1:10, 1:10)) : could not find function "CJ"
This is the bug. The function testFunction() can not find the data.table function CJ() despite the fact that data.table was imported.
However, if I have the package depend upon data.table, the problem goes away.
Looking at the sources for data.table 1.9.3 I see only one call of the form do.call(CJ...) it is in the file data.table.R in the function as.data.table.table() which provides some of the as() functionality for data.table and is registered with R through the setAs()
From this behaviour my guess is that functions registered through setAs() only have access to the globally available packages (The problem goes away when the import is replaced with a depends.). So, any functions registered through setAs() should not depend upon functions exported from data.table as these functions need not be available in the environment setAs() executed in.
So, my guess as to a solution would be to either re-implement the functionality of CJ() in the function as.data.table.table() or to find some other way of implementing as.data.table.table() that does not require a call to CJ().
The text was updated successfully, but these errors were encountered:
Submitted by: K Davis; Assigned to: Arun ; R-Forge link
I create a test package with the following setup
NAMESPACE:
DESCRIPTION:
R/testFunction.R:
For the full package see the attached tar.gz. I build the package, install it, and then use it as follows:
This is the bug. The function
testFunction()
can not find thedata.table
functionCJ()
despite the fact thatdata.table
was imported.However, if I have the package depend upon
data.table
, the problem goes away.Looking at the sources for data.table 1.9.3 I see only one call of the form
do.call(CJ...)
it is in the filedata.table.R
in the functionas.data.table.table()
which provides some of theas()
functionality fordata.table
and is registered with R through thesetAs()
From this behaviour my guess is that functions registered through
setAs()
only have access to the globally available packages (The problem goes away when the import is replaced with a depends.). So, any functions registered throughsetAs()
should not depend upon functions exported from data.table as these functions need not be available in the environmentsetAs()
executed in.So, my guess as to a solution would be to either re-implement the functionality of
CJ()
in the functionas.data.table.table()
or to find some other way of implementingas.data.table.table()
that does not require a call toCJ()
.The text was updated successfully, but these errors were encountered: