[Rcpp-devel] calling a homegrown cpp function from my own package when using sourceCpp
romain at r-enthusiasts.com
Mon Dec 30 09:24:56 CET 2013
If both these functions will end up in the same package, then I’d suggest to put both files in the src directory and use devtools::load_all on your package root directory.
Dirk’s recommendation is relevant bar is in its own package and calls foo from another package. Might not be what you want.
Le 30 déc. 2013 à 02:59, Søren Højsgaard <sorenh at math.aau.dk> a écrit :
> Dear all,
> I have created a function c++ function foo which I export with //[[Rcpp::export]]. I've put the file foo.cpp with the function into the src dir of the package mypack; I've run compileAttributes and I can see the function in mypack_RcppExport.h and the automatically generated interface to the function is available in R (these Rcpp-attributes really make life easier).
> Now I want to develop another function bar in the file bar.cpp and bar depends on foo. I want to develop bar using sourceCpp("bar.cpp") but I can not figure out how to make my c++ function foo available to bar. In bar.cpp I have
> //[[Rcpp::depends(mypack)]] but that does not make foo available.
> Is it possible to do what I want (I believe it is from the documentation?) or is there another "workaround"??
> Happy new year - and thanks in advance!
> Best regards
More information about the Rcpp-devel