[R] Compiling R code to native code?
Ben Bolker
bbolker at gmail.com
Sun Jan 29 02:37:23 CET 2012
Jeff Newmiller <jdnewmil <at> dcn.davis.ca.us> writes:
> 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.
> 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]]
Note that there is a fairly recently introduced byte-compiler
for R (library("compiler"); ?compile). There's also
http://www.milbo.users.sonic.net/ra/ , which looks a little out
of date by now (last release August 2011), but it might be
worht comparing. As Jeff said, though, there is usually room
for lots of speed improvement via vectorizing (or using add-on
packages such as data.table ). I *believe* typical speed-ups
from the built-in compiler are on the order of three-fold.
Porting to compiled languages (most popularly via Rcpp) can
give much higher speed-ups. For more information we'd really
need to know what you are trying to do. You might try searching
Stack Overflow for "[r] speed up" ...
More information about the R-help
mailing list