[Rcpp-devel] How to use functions from a R library in .cpp file

Yixuan Qiu yixuan.qiu at cos.name
Fri Jan 23 01:44:31 CET 2015


Hello,
There is an example showing the usage of Environment and Function in the
Rcpp Quick Reference Guide that is distributed with the package.
For your problem, it's something as follows:

NumericVector test()
{
    Environment pkg("package:mnormt");
    Function pmnorm = pkg["pmnorm"];
    NumericVector x = NumericVector::create(1, 0, 1);
    NumericVector mean = NumericVector::create(0, 0, 0);
    NumericMatrix cov(3, 3);
    cov(0, 0) = cov(1, 1) = cov(2, 2) = 1;
    return pmnorm(x, mean, cov);
}



Best,
Yixuan



2015-01-22 19:29 GMT-05:00 Li Li <llis at unm.edu>:

>  Hi,
>
>
>  I am trying to use the function "pmnorm" from R package "mnormt" in a
> .cpp file.
>
> I was wondering if anyone could help me with the following code so that I
> can use "pmnorm" somewhere in my sample function "epsilonij".
>
>
>  #include <RcppArmadillo.h>
> // [[Rcpp::depends(RcppArmadillo)]]
> using namespace arma;
>
> // [[Rcpp::export]]
>
> double epsilonij (double nu_i_lj, Rcpp::NumericVector w, ){
>   ....
> }
>
>
>  Thanks.
>
>
>  Li
>
> _______________________________________________
> 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
>



-- 
Yixuan Qiu <yixuan.qiu at cos.name>
Department of Statistics,
Purdue University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150122/4b31931b/attachment.html>


More information about the Rcpp-devel mailing list