On 19 May 2016 at 10:46, Paul Saary wrote: | Hello, | | I have been trying to solve this problem for quite some time now, so I | thought I'd ask here. | | I am trying to write a Cpp function, accepting multiple input types, | such as matrices and dataframes. | | I understood that I could do this by accepting any SEXP object. | | The core problem now is to transform these object into something my | software can use, which would be an object of type | std::vector<vector<double>>.
If you always use vector< vector< double > > then I would start with Rcpp::NumericMatrix, or arma::mat. Do you know if you prefer rows or columns? It is pretty easy to pick off either rows and columns, but you may save yourself a transpose. Lastly, maybe consider switching your code to arma::mat instead of vector< vector< double > > which is really a fudge to make up for the lack of proper Matrix classes in C++ itself. On 19 May 2016 at 11:12, Sameer D'Costa wrote: | Have you considered using the function as.matrix? It is an R function but you | can call it from within your Rcpp code as well. Once you have a matrix you can | use your matrix solution. I'd consider Rcpp::Function as a last resort. You do not need it here. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel