[Rcpp-devel] Hello world for Rcpp modules
Dirk Eddelbuettel
edd at debian.org
Fri Aug 12 16:59:55 CEST 2011
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
More information about the Rcpp-devel
mailing list