[Rcpp-devel] NumericVector wrapping an Armadillo vec is returned as a matrix

Davor Cubranic cubranic at stat.ubc.ca
Tue Apr 27 23:49:06 CEST 2010


In my code, I have an Armadillo column vector v (i.e., an 'arma::vec') that I return as a member of a list:

   arma::vec v(...);
   List result = List::create(_["v"] = v);

In R, result$v becomes a matrix, so I need to call 'as.vector(v)' to turn it into a vector. Even explicitly returning a NumericVector doesn't help, as in:

   arma::vec v(...);
   List result = List::create(_["v"] = NumericVector(wrap(v)));

Is this by design, a bug, or am I misusing the API?

Davor


More information about the Rcpp-devel mailing list