[Rcpp-devel] RInside: C/C++ function(s) passed to R?

Dirk Eddelbuettel edd at debian.org
Fri Nov 8 13:46:43 CET 2019


On 8 November 2019 at 10:06, LEVRA-JUILLET William wrote:
| I'm evaluating RInside/Rcpp to interact our C++ project with R.
| I've seen the samples to get/set data (matrix, dataframes, etc) to/from R and it builds/works fine.
| (Using gcc/mingw compiler from RTools on Windows)
| 
| My questions is about functions...
| My project is C++, and it uses RInside to call R from our code.
| Let's say I have a C++ function implemented in my project, and I want to pass that c++ function to R so it can be "used" as a R function (typically passed as argument to optim/optimize)
| I couldn't find a way to do that using RInside.

I think the passage of objects is unchanged. Rcpp does that.  The best
reference for me is still the RcppDE because _it does just that_ in the
context of optimisation: pass a user provided C++ function around.

Doing that from RInside should really work the same way. Same C++.

It has been used in a few places, as has the XPtr helper setup by Inaki which
he also mentioned to you.

Dirk

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


More information about the Rcpp-devel mailing list