[Rd] R-devel does not update the C++ returned variables

Dirk Eddelbuettel edd at debian.org
Mon Mar 2 15:43:25 CET 2015


On 2 March 2015 at 09:09, Duncan Murdoch wrote:
| I generally recommend that people use Rcpp, which hides a lot of the 
| details.  It will generate your .Call calls for you, and generate the 
| C++ code that receives them; you just need to think about the real 
| problem, not the interface.  It has its own learning curve, but I think 
| it is easier than using the low-level code that you need to work with .Call.

Thanks for that vote, and I second that.

And these days the learning is a lot flatter than it was a decade ago:

R> Rcpp::cppFunction("NumericVector doubleThis(NumericVector x) { return(2*x); }")
R> doubleThis(c(1,2,3,21,-4))
[1]  2  4  6 42 -8
R>

That defined, compiled, loaded and run/illustrated a simple function. 

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-devel mailing list