简体   繁体   English

如何确保R / Rcpp代码可重现(“可分发”)?

[英]How do I ensure R / Rcpp code is reproducible (“distributable”)?

I've written some R code for a dissertation, relying on some external packages (eg, plyr and reshape ) and writing a couple relatively simple inline C++ functions using inline and RcppArmadillo . 我已经为论文编写了一些R代码,依赖于一些外部包(例如, plyrreshape ),并使用inlineRcppArmadillo编写了几个相对简单的内联C ++函数。

I would like to ensure it can be performed "as is" on computers others than my own (Win64), for research reproducibility purposes. 我想确保它可以在我自己的计算机(Win64)上“按原样”执行,以用于研究再现性目的。

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? 我的问题:假设我包含了安装所需软件包的代码, RcppArmadillo (和Rcppinline )软件包是否足以能够编译RcppArmadillo编写的函数,或者最终用户是否需要更改系统路径以便在其上编译Windows机器? If not, is it possible/recommended to saved the compiled functions from my end and included in the R code I'm shipping? 如果没有,是否有可能/建议从我的结束保存编译的功能,并包含在我发货的R代码中?

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"? 此外,在不太可能的情况下代码应该运行一段时间(比如说,几年),在当前版本中包含完整的R安装以及相关软件包以使代码“面向未来”是足够的?

I hope the question is clear. 我希望这个问题很清楚。

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). “可重复”意味着前一个问题是正确的,并且增加了结果相同的限制(直到你选择的epsilon)。

And the usual answer for 'how can I let others run my R code' is to create a package. “如何让其他人运行我的R代码”的通常答案是创建一个包。

For Rcpp-related code, we have an entire vignette devoted to building your own package with your Rcpp-using cod. 对于与Rcpp相关的代码,我们有一个完整的小插图致力于使用您的Rcpp-using cod构建您自己的包。 The vignette is called 'Rcpp-package'. 小插图被称为'Rcpp-package'。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM