On 24 May 2013 at 05:17, Peng Yu wrote: | I want to put the C++ function "callFunction" in a cpp file in src/ | directory of an R package and use R (in R/) to call such a function. | Because I want to avoid the compilation need each time to use the | function. Could anybody show me an example how to do so? Thanks.
Read the R documentation manual "Writing R Extensions" to learn the basics about packages and they are created. Read the vignette "Rcpp-package" to learn about creating a package with Rcpp (hint: use Rcpp.package.skeleton). Stick callFunction() in that package. (Note though that just because you call an R function from C++ does NOT accelerate that R function. It is still an R function, and as fast or slow as before. But yes, you can call it from C++.) Dirk -- Dirk Eddelbuettel | [email protected] | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
