[Rcpp-devel] Transform arbitrary R object into std::vector<vector<double>>

To Duc Khanh toduc at stat.unipd.it
Thu May 19 15:31:28 CEST 2016


Hi, Paul Saary

For a data.frame, you should use as.matrix(data.frame) before use its in
C/C++ function. That is my experiment.

>
> On 19 May 2016 at 12:47, Paul Saary wrote:
> | Thank you for your reply,
> |
> | > If you always use vector< vector< double > > then I would start with
> | > Rcpp::NumericMatrix, or arma::mat.
> |
> | The problem is, that I want to offer the user a choice of using also
> | data.frames and not just Matrices. So I can not really decide, with what
> | I start, or am I wrong?
>
> Yes :)
>
> A data.frame is simply not a matrix. It allows different types. Which you
> cannot represent here.
>
> | Regarding the use of Rcpp:function:
> | As the R objects used are very large (many MB to some GB), I would like
> | to do the transformation into a usable format, in my case into the
> | vector< vector< double > >, in CPP, as I imagine it to be much faster.
>
> Imagination can be a dangerous thing. Most of us prefer profiling.
>
> | I will have look into armadillo, but I hoped to avoid loading another
> | library, to reduce the depencies of my script/package.
>
> Please do look into it. It is worth it. And the added size, relative to
> the
> footprint you already have with R, is marginal.  And there is none at
> run-time -- C++ and all that.
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>


-- 
Khanh To Duc
PhD student, Department of Statistical Science, XXIX cycle.
Office: Room 130
Telephone: +39 049 827 4147
Mobile: +39 345 667 0711
http://www.stat.unipd.it/it/fare-ricerca/duc-khanh



More information about the Rcpp-devel mailing list