[R] compile c code from R

Jason Turner jasont at indigoindustrial.co.nz
Wed Jul 30 21:47:09 CEST 2003

Ximing Wu wrote:
> Hi,
> Can I turn my R code automatically into C? If yes, how can I do that? Do I
> benefit by doing it?

Nope. But the R language libraries can be compiled as a dynamic library, 
and linked to from C.  This still means writing your own C code to run 
the R functions, however.

The extra effort *may* be worth it for some applications that are fairly 
static in their development/application (ie few ongoing tweaks).  I 
haven't found any advantage for my own work, however.

> (I know I can do this in matlab and it increases the speed when there is a
> lot of looping...)

There are others on this list who've tried this sort of benchmarking.

For me, saving hours of development time is well worth the extra seconds 
or minutes of code execution time.  And it's far from clear it's costing 
me that much in execution time.


Indigo Industrial Controls Ltd.
jasont at indigoindustrial.co.nz

More information about the R-help mailing list