<div dir="ltr"><div><div><div><div>Hello,<br><br></div>I'm trying to calculate principal component using 'princomp' function from RcppArmadillo. Here's the cpp code:<br><br>#include <RcppArmadillo.h><br>
<br>RcppExport SEXP pca(SEXP mats) { <br> try {<br> <br> Rcpp::NumericMatrix matr(mats);<br> int n = matr.nrow(), k = matr.ncol(); <br><br> arma::mat mat(matr.begin(), n, k, false);<br> arma::colvec pca;<br>
<br> pca = arma::princomp(mat);<br> <br> return Rcpp::wrap(mat);<br> <br> } catch(...) {<br> ::Rf_error("c++ error");<br> }<br>}<br><br></div>However, when I "R CMD check" the package, I get the following error:<br>
<br>** testing if installed package can be loaded<br>Error in dyn.load(file, DLLpath = DLLpath, ...) : <br> unable to load shared object '/home/tecto/cpp/Rcpp/amora.Rcheck/amora/libs/amora.so':<br> /home/tecto/cpp/Rcpp/amora.Rcheck/amora/libs/amora.so: undefined symbol: dgesvd_<br>
Error: loading failed<br>Execution halted<br><br></div>I've read the Armadillo documentation for that function (<a href="http://arma.sourceforge.net/docs.html#princomp">http://arma.sourceforge.net/docs.html#princomp</a>), however it was not clear to me how to use it correctly.<br>
<br></div>Does my code have any mistake?<br><br>Cheers,<br><br>Joćo Daniel<br></div>