Hi All, I've been working on an Rcpp based package (for the better part of a year and a half now), and have a few issues that I was hoping I could get some help with. As a bit of background, this package fits (via MCMC-MLE) exponential family random graph models (ergm), markov random field models, and a new generalization of the two (un-creatively titled) exponential random network models (ernm). More full info on the math is available at [1], and some obtuse notes toward a vignette are at [2]. You can download the package source from [3]. The package uses Rcpp modules extensively to pass large C++ objects up and down between R and C++ transparently, and with no deep copies. Problem 1: on R CMD check I get a namespace loading warning. I believe this was discussed on list some time ago, but there wasn't a resolution offered that I could see. I tried adding imports(methods) to the namespace, to no avail. The warning is: ** checking whether the namespace can be loaded with stated dependencies ... WARNING Error in value[[3L]](cond) : failed to load module ernm from package ernm could not find function "getClass" Error: .onLoad failed in loadNamespace() for ?ernm?, details: call: fun(libname, pkgname) error: could not find function "initErnmStatistics" Execution halted Problem 2: I want to make the package extensible so that other packages can extend the C++ classes, and so that they can be used via inline. I tried to make an inline plug-in (see: inline.R), but have gotten stuck. Any guidance here is appreciated. Problem 3: This isn't an Rcpp question per se, but? I have some C++ tests in a subdirectory of src (src/tests), I would like to export them to R so that they can be run on R CMD check but R doesn't seem to be compiling them correctly. How do I modify MakeVars to compile the subdirectory? Any comments on the code itself are also more than welcome. It is still very much research code, so I'm sure that there are many ways to break it. Best, Ian [1] http://fellstat.com/files/ifellows.pdf [2] http://fellstat.com/files/ernm.pdf [3] http://fellstat.com/files/ernm_1.0.tar.gz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121110/7a797f8c/attachment.html>
[Rcpp-devel] inline and namespace loading issues for new package
4 messages · Ian Fellows, Dirk Eddelbuettel
On 10 November 2012 at 19:22, Ian Fellows wrote:
| Hi All, | | I've been working on an Rcpp based package (for the better part of a year and a | half now), and have a few issues that I was hoping I could get some help with. | | As a bit of background, this package fits (via MCMC-MLE) exponential family | random graph models (ergm), markov random field models, and a new | generalization of the two (un-creatively titled) exponential random network | models (ernm). More full info on the math is available at [1], and some obtuse | notes toward a vignette are at [2]. You can download the package source from | [3]. | | The package uses Rcpp modules extensively to pass large C++ objects up and down | between R and C++ transparently, and with no deep copies. We think we are about to release a new version. It will, among other things, bring a few new exciting things to Modules (as Romain already hinted on his blog earlier in the week). So maybe we should take this one question at a time. | Problem 1: on R CMD check I get a namespace loading warning. I believe this was | discussed on list some time ago, but there wasn't a resolution offered that I | could see. I tried adding imports(methods) to the namespace, to no avail. The | warning is: | | ** checking whether the namespace can be loaded with stated dependencies ... | WARNING | Error in value[[3L]](cond) : failed to load module ernm from package ernm | could not find function "getClass" Quick guess: Maybe force load / import of package 'methods' ? More on the other questions in a few days. Let's take them one by one. Dirk | Error: .onLoad failed in loadNamespace() for ?ernm?, details: | call: fun(libname, pkgname) | error: could not find function "initErnmStatistics" | Execution halted | | Problem 2: I want to make the package extensible so that other packages can | extend the C++ classes, and so that they can be used via inline. I tried to | make an inline plug-in (see: inline.R), but have gotten stuck. Any guidance | here is appreciated. | | Problem 3: This isn't an Rcpp question per se, but? I have some C++ tests in | a subdirectory of src (src/tests), I would like to export them to R so that | they can be run on R CMD check but R doesn't seem to be compiling them | correctly. How do I modify MakeVars to compile the subdirectory? | | Any comments on the code itself are also more than welcome. It is still very | much research code, so I'm sure that there are many ways to break it. | | Best, | Ian | | | | [1] http://fellstat.com/files/ifellows.pdf | [2] http://fellstat.com/files/ernm.pdf | [3] http://fellstat.com/files/ernm_1.0.tar.gz | | ---------------------------------------------------------------------- | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel at lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Dirk,
Quick guess: Maybe force load / import of package 'methods' ? More on the other questions in a few days. Let's take them one by one.
I had already added methods to the namespace via import in the NAMESPACE file, and added it to the depends in the DESCRIPTION file. I just tried adding an explicit library(methods) to .onLoad, which fixed the warning, but now gives me:
* checking R code for possible problems ... NOTE
File ?ernm/R/zzz.R?:
.onLoad calls:
library(methods)
Package startup functions should not change the search path.
See section ?Good practice? in ?.onAttach.
Best,
ian
On 10 November 2012 at 23:34, Ian Fellows wrote:
| Dirk,
|
| >
| > Quick guess: Maybe force load / import of package 'methods' ?
| >
| > More on the other questions in a few days. Let's take them one by one.
|
|
| I had already added methods to the namespace via import in the NAMESPACE file, and added it to the depends in the DESCRIPTION file. I just tried adding an explicit library(methods) to .onLoad, which fixed the warning, but now gives me:
Ok, sorry.
| * checking R code for possible problems ... NOTE
| File ?ernm/R/zzz.R?:
| .onLoad calls:
| library(methods)
|
| Package startup functions should not change the search path.
| See section ?Good practice? in ?.onAttach.
Modules no longer need to be loaded via .onLoad. Here is eg what the little
RcppCNPy (which I wrote over the summer) does:
edd at max:~$ cat svn/rcpp/pkg/RcppCNPy/R/*
loadModule("cnpy", TRUE)
edd at max:~$
That is the _entire_ R/ directory -- one line. This example is a little
extreme, of course, but as far as loading goes... all you need is
loadModule() and the second argument even defaults to TRUE as I recall.
The package is on CRAN if you want to take a quick peek.
I'm off for a run now and soccer game of daughter #1 later but will be back
home most of the (Central time) afternoon so maybe we can try a few things
off-list.
Your feedback in making the "Rcpp modules" vignette better is appreciated.
Dirk
| Best,
| ian
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com