I find it difficult to figure out how to return RcppArmadillo colvec as a standard R-vector. I was hoping I could type in as<NumericVector>(wrap() , but I still get objects with R matrices. Here is some code to show what I tried (partially inspired by this previous question ):
// [[Rcpp::export]] List testthis(NumericVector x) { arma::colvec y = x; arma::vec z = x; return List::create(Rcpp::Named("y1")=y, Rcpp::Named("y2")=wrap(y), Rcpp::Named("y3")=as<NumericVector>(wrap(y)), Rcpp::Named("z1")=z, Rcpp::Named("z2")=arma::trans(z), Rcpp::Named("z3")=as<NumericVector>(wrap(z)) ); }
and if I look at the result, I get the following: all R-matrix objects. Can I attribute it to R-vectors?
> testthis(c(1:3)) $y1 [,1] [1,] 1 [2,] 2 [3,] 3 $y2 [,1] [1,] 1 [2,] 2 [3,] 3 $y3 [,1] [1,] 1 [2,] 2 [3,] 3 $z1 [,1] [1,] 1 [2,] 2 [3,] 3 $z2 [,1] [,2] [,3] [1,] 1 2 3 $z3 [,1] [1,] 1 [2,] 2 [3,] 3