[R] Compiling R code to native code?

Bert Gunter gunter.berton at gene.com
Sun Jan 29 02:47:27 CET 2012


Facts:

1. R does not by default compile bytecode. It uses a read-parse-eval
cycle as described in the R Language Manual.

2. However, as of 2.14.0 (anyway) there is a "compiler" package that
is shipped as part of the standard distribution. Written by Luke
Tierney and his graduate student minions, it is described here:
http://www.divms.uiowa.edu/~luke/R/compiler/compiler.pdf

As usual, it can result in considerable speedup, though vectorization
is still a good strategy when possible.

To be clear, Jeff's original reply is correct -- R is interpreted, not compiled.

Cheers,
Bert

On Sat, Jan 28, 2012 at 5:01 PM, Jeff Newmiller
<jdnewmil at dcn.davis.ca.us> wrote:
> Nope. Most users get speed by using vectorized calculations. If you have already identified how to get correct answers, the next step is something like Rcpp or linking to a shared library written in your language of choice.
>
> But seriously, vectorizing is enough for most applications, and making sure the answer is right doesn't usually require compiled code.
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
>                                      Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
>
> Gregory Propf <gregorypropf at yahoo.com> wrote:
>
>>Simple question: is there a way to compile R scripts to native code?
>>�If not is there anything else that might improve speed? �I'm not even
>>sure that R compiles internally to byte code or not. �I assume it does
>>since all modern languages seem to do this. �Maybe there's a JIT
>>compiler? �Yes, I have searched Google and get lots of stuff that's
>>seems confusing. �I just want to know what packages to install and how
>>to use them to generate binaries if they exist.
>>       [[alternative HTML version deleted]]
>>
>>______________________________________________
>>R-help at r-project.org mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list