Testing newly installed Rcpp
By tholscla on Wed, 06/11/2014 - 12:18
This is a quick test Rcpp module to ensure Rcpp was installed and linked properly to R. Just run these lines of code in R and the answer should be 9 at the end.
library(Rcpp)
library(inline)
fx <- cxxfunction(,"",includes=
' double add(double c,double d)
{ double e=0;
e=c+d;
return e;
}
RCPP_MODULE(foo)
{ function( "add", &add ) ;}
', plugin="Rcpp")
foo <- Module("foo",getDynLib(fx))
foo$add(4,5) #answer is 9