Reputation: 791
I'm trying to make an R package to export my R function called function1 and uses some R data elements. So, I created a package skeleton using:
package.skeleton(list=c("function1",
"data1.data",
"data2.data",
"data3.data",
), name="mypackage")
In the NAMESPACE file, I have the lines:
exportPattern("^[[:alpha:]]+")
export(data1.data, data2.data, data3.data)
After building this package, I install the package using install.packages('mypackage.tar.gz',,type='source',repos=NULL)
The installation is successful, but when I try to run function1 I get the error:
Error in namespaceExport(ns, exports) :
undefined exports: data1.data, data2.data, data3.data
How do I export these data elements correctly? I thought the export(data1.data...) lines in the NAMESPACE file would do it, but apparently not. I tried reading the R manual but it seems very confusing on the NAMESPACE point and mostly about how to export python or C++ data. I just want to export a function and some data that's all in R.
Upvotes: 0
Views: 168
Reputation: 791
Figured it out. Turns out that I shouldn't put export(data1...) in the NAMESPACE file.
Instead, data is loaded separately after the library(mypackage) call by calling:
data('data1.data');
data('data2.data');
data('data3.data');
Upvotes: 1