[Rcpp-devel] Hello world for Rcpp modules

Chris DuBois chris.dubois at gmail.com
Fri Aug 12 17:07:29 CEST 2011


Yes, that fixes the problem.

Apologies and thanks,
Chris

On Fri, Aug 12, 2011 at 7:59 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> Got it now:  you cannot just drop code in an R file, that has nothing to do
> with Rcpp methinks.   Wrap it in a function like so:
>
> edd at max:/tmp$ R CMD INSTALL chrisExample/
> * installing to library ‘/usr/local/lib/R/site-library’
> * installing *source* package ‘chrisExample’ ...
> ** libs
> make: Nothing to be done for `all'.
> installing to /usr/local/lib/R/site-library/chrisExample/libs
> ** R
> ** preparing package for lazy loading
> ** help
> Warning: /tmp/chrisExample/man/chrisExample-package.Rd:32: All text must be
> in a section
> Warning: /tmp/chrisExample/man/chrisExample-package.Rd:33: All text must be
> in a section
> *** installing help indices
> ** building package indices ...
> ** testing if installed package can be loaded
>
> * DONE (chrisExample)
> edd at max:/tmp$ r -lchrisExample  -e'chris()'
> C++ class 'World' <0x2a55d60>
> Constructors:
>    World()
>
> Fields: No public fields exposed by this class
>
> Methods:
>     std::string greet()
>           docstring : get the message
>     void set(std::string)
>           docstring : set the message
> edd at max:/tmp$ cat chrisExample/R/rcpp_hello_world2.R
>
> chris <- function() {
>     show(World)
>    b <- new(World)
>    b$greet()
>    b$set("hello everybody")
>    b$greet()
>    rm(b)
>
>     invisible(NULL)
> }
> edd at max:/tmp$
>
> Ok?
>
> Dirk
>
> --
> Two new Rcpp master classes for R and C++ integration scheduled for
> New York (Sep 24) and San Francisco (Oct 8), more details are at
>
> http://dirk.eddelbuettel.com/blog/2011/08/04#rcpp_classes_2011-09_and_2011-10
>
> http://www.revolutionanalytics.com/products/training/public/rcpp-master-class.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110812/b9700bd1/attachment.htm>


More information about the Rcpp-devel mailing list