[Rcpp-devel] How to export a .Call function in a closure?

Dirk Eddelbuettel edd at debian.org
Tue Aug 28 13:06:59 CEST 2012

On 27 August 2012 at 22:36, Peng Yu wrote:
| I have the following two functions which wrap a C++ function differently.
| rcpp_hello_world=local({
|   sym=getNativeSymbolInfo('rcpp_hello_world', PACKAGE='mypkg')
|   function() .Call(sym, PACKAGE='mypkg')
| })
| rcpp_hello_world1=function(){
|   .Call('rcpp_hello_world', PACKAGE='mypkg')
| }
| However, the first one results in some error, when I try to install
| the R package. I guess the problem is that when the package is being
| installed, "mypkg" is not available yet. The solution might be to put
| some code in .onLoad or some code that is executed when the package is
| loaded (not at installation time). However, I don't find an example.
| Does anybody have any experience on how to have the first form of
| .Call in a package? Thanks!
| Loading required package: Rcpp
| Error in FUN("rcpp_hello_world"[[1L]], ...) :
|   no such symbol rcpp_hello_world in package mypkg
| Calls: roxygenize ... eval -> eval -> getNativeSymbolInfo -> lapply -> FUN
| Execution halted

You posted two methods.  One of which works and is supported.  Why not use it?


Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  

More information about the Rcpp-devel mailing list