Rcpp

Generic wrapper

###### Libraries
library(Rcpp)
library(inline)

###### wrapper
fx <- cxxfunction(,"",includes=
  '
**********FILL FUNCTIONS IN HERE************
RCPP_MODULE(foo)
   {   function( "functionname1", &functionname1 ) ;
       function( "functionname2", &functionname2 ) ;
   }
', plugin="Rcpp")
foo <- Module("foo",getDynLib(fx))

 

Dot product (dot)

Multiply two vectors together using a dot product.

double dot(Rcpp::NumericVector c,Rcpp::NumericVector d)
   {     int nc= c.size();
         double e=0;
         for (int i = 0; i < nc; i++)
         {  e=e+c(i)*d(i); }
         return e;
   }

3D arrays

Seemlessly pass three dimensional arrays between between R and Rcpp.  I found a function called threeDIndex on a forum written for Rcpp  but it did not convert from R to  Rcpp smoothly. I needed to be passing these 3D arrays back and forth not just using them in Rcpp.  I re-wrote the threeDIndex code (mythreeDIndex code) that works seemlessly with the R coverterts c() and array().

Programming

Bayesian residual plot

I am making available some basic functions that I use often.  If you have a recommendation about how I coded something or find a bug, please leave a comment.  I write R packages with a mix of R functions and compiled C++ functions (Rcpp library) for speed/efficiency.  Code is not guarenteed to work, use at your own risk.

R code and packages

Rcpp (R and C++) functions

Basic Regression Tutorial

 

Pages