// Simple example of using RInside to call Portfolio Probe within C++ // adapted from examples by Dirk Eddelbuettel and Romain Francois #include // for the embedded R via RInside int main(int argc, char *argv[]) { try { RInside R(argc, argv); // create an embedded R instance std::string txt = "suppressMessages(library(PortfolioProbeBeta))"; R.parseEvalQ(txt); // load library, no return value txt = "Var <- var(cbind(ABC=rnorm(10), DEF=rnorm(10))); Var"; Rcpp::NumericMatrix Var = R.parseEval(txt); // assign mat. Var to NumericMatrix txt = "Pri <- c(ABC=34.86, DEF=29.73); Pri"; Rcpp::NumericVector Pri = R.parseEval(txt); std::cout << "Var has " << Var.nrow() << " rows and " << Var.ncol() << " columns" << std::endl; txt = "colnames(Var)"; // assign columns names of Var to ans and Rcpp::CharacterVector cnames = R.parseEval(txt); // into str.vec. cnames for (int i=0; i