[R] Rcpp module / class access

Pascal A. Niklaus Pascal.Niklaus at ieu.uzh.ch
Tue Mar 3 11:45:38 CET 2015


Dear all,

I am struggling accessing a class created in an Rcpp module.

The structure of the package is essentially the one created using:

Rcpp.package.skeleton(name="testPackage",module=TRUE)


Now, after loadiong the package with library(testPackage), I can create 
instances of the "World" class as follows:

library(testPackage)
mod_yada<-Rcpp::Module("yada",PACKAGE="testPackage",mustStart=TRUE)
w <- new(mod_yada$World);

So far so good.


However, I fail defining a S4 wrapper class within the same package. As 
part of that, I would like to define a generator function that returns 
an instance of mod_yada$World, as in the code above:

However, "yada$World" is not accessible.

I then tried inserting the following line in the respective R file 
(although I thought this was already taken care by the 
"loadModule("yada", TRUE)" that was places in zzz.R by the skeleton 
generator:

mod_yada<-Rcpp::Module("yada",PACKAGE="testPackage",mustStart=TRUE)

But again, this fails with:

  Failed to initialize module pointer: Error in 
FUN("_rcpp_module_boot_mod_yada"[[1L]], ...): no such symbol 
_rcpp_module_boot_mod_yada in package testPackage


Putting this file after zzz.R in the Collate: list in the DESCRIPTION 
file also does not help.


How can I define this in the Rcpp package itself?


Thanks for any hint

Pascal Niklaus



More information about the R-help mailing list