[Rcpp-devel] vector<string> -> SEXP
Romain François
francoisromain at free.fr
Mon Nov 9 17:56:27 CET 2009
Hi,
Is there some utility in Rcpp that would convert a vector<string> into a
STRSXP SEXP ?
Something like this:
SEXP res = PROTECT( Rf_allocVector( STRSXP, size ) ) ;
int i =0;
for( vector<string>::const_iterator iter = elements.begin(); iter !=
elements.end(); ++iter, ++i ) {
SET_STRING_ELT( res, i, Rf_mkChar( iter->c_str() ) ) ;
}
UNPROTECT(1) ; /* res */
return res ;
If not, where should it be ? RcppStringVector, or some other class ?
Romain
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/EAD5 : LondonR slides
|- http://tr.im/BcPw : celebrating R commit #50000
`- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
More information about the Rcpp-devel
mailing list