[Rcpp-devel] Using an Rcpp module package in an R Reference Class

Christian Gunning xian at unm.edu
Tue Oct 14 22:42:00 CEST 2014


On Tue, Oct 14, 2014 at 9:19 AM, Dr Gregory Jefferis
<jefferis at mrc-lmb.cam.ac.uk> wrote:
>
>> * Rcpp: RCPP_EXPOSED_CLASS_NODECL(RaggedArray)
>> * Rcpp: setRcppClass("RaggedArray")
>> * roxygen2/NAMESPACE:  @exportClass RaggedArray
>
> I'm not sure if the exact issue here, but you could look at this package
> that I wrote:
>
> https://github.com/jefferis/nabor
>
> and in particular
>
> https://github.com/jefferis/nabor/blob/master/R/WKNNClasses.R
> https://github.com/jefferis/nabor/blob/master/src/WKNN.cpp
>

Yeah, I found your package and used it as a prototype to fix a few
things, but I'm honestly still short on understanding.  Here's my
reading of the above 3 *s:

* I've read ?setRcppClass, and looked at the definition (e.g.
Rcpp::setRcppClass) and I'm not clear on when this is required, and
whether its RefClass or S4.

* The best explanation of the RCPP_EXPOSED_CLASS macro I found was
here: http://romainfrancois.blog.free.fr/index.php?post/2012/10/25/Rcpp-modules-more-flexible.
My understanding is that this only involves the C++ side, and is
totally unrelated to a pure-R reference class using an Rcpp module
object and its methods.

* The @exportClassses directive creates an exportClasses entry in
NAMESPACE.  Looking at "Writing R extensions", it looks like this is
particular to S4 classses.  In fact, I can't find mention of reference
classes in "Writing R extensions".  So, I'm murky on what calling
exportClasses(myRcppModule) actually does, or how it works.

Did I miss anything here?
Thanks!
Christian

-- 
A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!


More information about the Rcpp-devel mailing list