简体   繁体   English

编译R代码时的选项

[英]Options when compiling R code

I usually just copy-paste (or source(..) ) my R code on a console, so that compilation in R is very obscure to me. 我通常只是在控制台上复制粘贴(或source(..) )我的R代码,所以R中的编译对我来说是很晦涩的。

When compiling C++ code, one can give indication to the compiler (such as #define or #pragma for example) or specific flag to indicate level of optimization (such as -o2 for example). 在编译C ++代码时,可以给编译器一个指示(例如#define#pragma )或特定的标志来指示优化级别(例如-o2 )。

Is there an equivalent of #InfoForCompiler or -o2 in R? R中是否有#InfoForCompiler-o2的等效项? Is it possible to make specific choices about how and when (when defining the function or when calling the function for the first time) an R code is compiled? 是否可以对R代码的编译方式和时间(在定义函数或首次调用函数时)进行特定选择?

Whichever way you choose to compile, from R CMD COMPILE to R CMD INSTALL for a package, or via something like Rcpp::sourceCpp() , it will always be invoked by R itself and 无论选择哪种编译方式,都可以从R CMD COMPILER CMD INSTALL进行R CMD COMPILE ,也可以通过Rcpp::sourceCpp()类的方式进行编译,而该编译将始终由R本身和

  • R respect environment variables like CXXFLAGS R尊重环境变量,例如CXXFLAGS
  • R looks up its values in $RHOME/etc/Makeconf (on Debian systems also in /etc/R/Makeconf R在$RHOME/etc/Makeconf查找其值(在Debian系统上也位于/etc/R/Makeconf
  • These can be overriden via ~/.R/Makeconf on a per-user basis. 可以按每个用户通过~/.R/Makeconf覆盖它们。

But as @nrussell commented this will not affect your already-compiled R interpreter, only incremental new compilations -- for example package installations. 但是正如@nrussell所评论的那样,这不会影响您已经编译的R解释器,只会影响新的增量编译-例如软件包安装。

To change this for R itself, you have to essentially rebuild R from source. 要更改R本身,必须从源头上重建R。

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

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