[Rd] Create and access several instances of a C++ class from R

soeren.vogel at uzh.ch soeren.vogel at uzh.ch
Fri May 13 16:19:16 CEST 2011


On 07.05.2011, at 11:15, Romain Francois wrote:

> Try having do_bar with this signature:
> 
> void do_bar(NumericVector data);
> 
> And my advice would probably also to have your C field either as a NumericVector. NumericVector is just a thin wrapper around the internal R data structure.
> 
> Having data members as direct pointers is dangerous and not a very C++ way of doing things.
> 
> If you want to learn about the STL, there are many books that cover it and plenty of online resources. I use this : http://cplusplus.com/reference/stl/. Using the STL is easier than dealing with pointers and stuff.
> 
> If your game is to pass down a double* to some api you use, you can use the begin method of NumericVector, this will give you the array pointer (as would REAL do on the underlying SEXP):

[...]

For the files: the discussion continues here:

http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2011-May/002261.html

Regards
Sören



More information about the R-devel mailing list