Skip to content

Instantly share code, notes, and snippets.

@Dulani
Created August 5, 2017 03:17
Show Gist options
  • Save Dulani/3da26afead3317fb9bd4e423fdedd3f9 to your computer and use it in GitHub Desktop.
Save Dulani/3da26afead3317fb9bd4e423fdedd3f9 to your computer and use it in GitHub Desktop.
A VERY simple example using C++ in R with the cppFunction() function.
#' Copied from Dirk Eddelbuettel's 2017 Rcpp Tutorial
#' http://dirk.eddelbuettel.com/papers/useR2017_rcpp_tutorial.pdf
#A very impressive little adaptation:
cppFunction(”
double m(int n, double x) {
for (int i=0; i<n; i++)
x = 1 / (1+x);
return x;
}”
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment