From edd at debian.org  Mon Mar  2 15:43:25 2015
From: edd at debian.org (Dirk Eddelbuettel)
Date: Mon, 2 Mar 2015 08:43:25 -0600
Subject: [Rd] R-devel does not update the C++ returned variables
In-Reply-To: <54F46F15.3030901@gmail.com>
References: <CAHyAz7TOELUyX2XW=8Abvuz2tU0_ZXVuyx-B84RBk7TQyM-mAA@mail.gmail.com>
	<54F45105.40608@gmail.com>
	<CAHyAz7QvAyL-KgKp0B6pk=RDHAQs2LHeGS48HvATqZnbuoAfww@mail.gmail.com>
	<54F46F15.3030901@gmail.com>
Message-ID: <21748.30477.886575.819346@max.nulle.part>


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



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