This is somewhat related to the post regarding moving from sourceCpp to a package with Rcpp Moving from sourceCpp to a package w/Rcpp. However, I am using RcppArmadillo on a Mac OS X 10.10.4 and have had trouble getting a package to work. The file that works with sourceCpp is as follows:
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
// [[Rcpp::export]]
arma::mat cholcalcCpp(arma::mat& SS, arma::umat& Aadj){
int p = SS.n_rows;
arma::mat L(p,p);
arma::mat D(p,p);
L = arma::eye(p,p);
D = arma::eye(p,p);
return (L*sqrt(D));
}
Trying to use R Studio to create a new project using Project>Create Project>Package w/Rcpp didn't work either because I kept getting an error saying that command arma wasn't recognized. I tried adding the #include <RcppArmadillo.h>
in the RccpExports.cpp file, but Rstudio deletes that line every time I try to build and reload. Can anyone suggest how I can go from the .cpp file to a RccpArmadillo package? Thanks.