[R] pass a vector to C++

Dirk Eddelbuettel edd at debian.org
Fri Jun 26 03:29:24 CEST 2009


On 25 June 2009 at 17:39, Ivo Shterev wrote:
| Does anyone know how to pass a vector of strings, for example "c("1", "2",
| "3") to a C++ function? Should the input argument to the C++ function be
| vector<string>*? 

For the basic mechanics of making R and C/C++ talk, see the 'R Extensions'
manual that came with your copy of R, or find it on CRAN.

For a higher level of abstraction, you may find my Rcpp package (on CRAN,
r-forge and at http://dirk.eddelbuettel.com/code/rcpp.html) useful.  It does
indeed allow you to use c("1", "2", "3") as vector<std::string> (after one
cast from RcppStringVector).

Dirk

-- 
Three out of two people have difficulties with fractions.




More information about the R-help mailing list