[Rcpp-devel] How do I load a rcpp module?

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Mar 12 10:54:17 CET 2012


Hi Glenn,

On Mon, Mar 12, 2012 at 5:26 AM, Glenn Lawyer <lawyer at mpi-inf.mpg.de> wrote:
> Dear List,
>
> I am working through the vingette "Exposing C++ functions and classes with
> Rcpp modules," and am stuck at section 2.2.1.
>
> I create a text file with the code for the Uniform class, and successfully
> compile it with R CMD SHLIB.
>
> Can you please tell me how to load it into R so that I can continue with the
> example? The vingette clearly shows how to use it once everything is set up,
> but does not show how to set things up.

I suspect they want you to either whip the functionality you are using
to create a module from into a package of sorts (some documentation
for that is at the end of the vignette, but also in other (non
Module-specific) Rcpp vignettes).

You can alternatively try to load the shared library once you `R CMD
SHLIB` it using `dyn.load` (see ?dyn.load). You will definitely need
to have Rcpp loaded in your workspace first, though.

That may or may not work w/ modules, though ... I never tried, but:

> This is, in fact, my main frustration with all of the rcpp documentation. It
> consistently assumes a high level of sophistication from its users. Almost
> none of the examples work "as is", nor do they give hints as to what
> information is missing.

I don't know how fair of a complaint that is ... at a minimum, I think
you should be familiar with the concepts in the "Writing R Extensions"
manual:

http://cran.r-project.org/doc/manuals/R-exts.pdf

and I don't think it's really unfair for the devs to assume that as a
starting point.

I guess you're somehow right in the sense that reading through that
requires a bit of R sophistication, but what you're trying to do w/
Rcpp is sophisticated :-)

Also, the examples using `inline` are the ones you can get away with
doing w/o having some R know-how, but once you get into the world of
trying to compile external C++ code and include it "seamlessly" into
R, you really should do a bit of h/w on the R library/package building
process (the R-exts doc above).

Hope that helps,
-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact


More information about the Rcpp-devel mailing list