Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I ensure R / Rcpp code is reproducible ("distributable")?

I've written some R code for a dissertation, relying on some external packages (e.g., plyr and reshape) and writing a couple relatively simple inline C++ functions using inline and RcppArmadillo.

I would like to ensure it can be performed "as is" on computers others than my own (Win64), for research reproducibility purposes.

My question: suppose I included code for installing the required packages, would the RcppArmadillo (and Rcpp and inline) packages be sufficient to be able to compile the functions written in RcppArmadillo, or would the end user need to change system paths for compilation on his Windows machine? If not, is it possible/recommended to saved the compiled functions from my end and included in the R code I'm shipping?

Also, in the unlikely case that the code should be run some time later (say, a couple of years), is it suffient to include a full R installation with the relevant packages in their current version to make the code "future-proof"?

I hope the question is clear.

like image 697
MatteoS Avatar asked Aug 23 '12 20:08

MatteoS


1 Answers

I think you mean your code to be "distributable" and "executable by someone else" which is a looser requirement. Being "reproducible" implies that the previous question is a true, and adds the restriction that the results are identical (up to the an epsilon of your choice).

And the usual answer for 'how can I let others run my R code' is to create a package.

For Rcpp-related code, we have an entire vignette devoted to building your own package with your Rcpp-using cod. The vignette is called 'Rcpp-package'.

like image 65
Dirk Eddelbuettel Avatar answered Sep 20 '22 12:09

Dirk Eddelbuettel