[Rcpp-devel] Convertion from SEXP to std::vector<unsigned>

Peng Yu pengyu.ut at gmail.com
Wed Aug 22 16:55:01 CEST 2012


Hi,

Rcpp::IntegerVector can not be converted to std::vector<unsigned>. Is
there a class that can help convert SEXP to std::vector<unsigned>?

The current walkaround can be something like the following. I'm
wondering if there is a better solution?

Rcpp::IntegerVector vec(vx);

std::vector<unsigned> v;
for (int i=0; i<vec.size(); i++) {
v.push_back(vec[i]);
}

-- 
Regards,
Peng


More information about the Rcpp-devel mailing list