[Rd] C vs. C++ as learning and development tool for R

Vladimir Dergachev vdergachev at rcgardis.com
Fri Jan 19 19:51:25 CET 2007

On Friday 19 January 2007 1:29 pm, Gabor Grothendieck wrote:
> > If you decide to use C++ with R you should check out the documentation
> > that comes with the package RcppTemplate, and the sample code that
> > comes with that package. In my experience C++ (or C or FORTRAN) is
> > needed for many compute intensive tasks, and the R framework provides
> > a nice front-end with its extensive collection of visualization and
> > statistical analysis tools.
> Actually I have found the opposite. I have never found C/C++ to be
> necessary. I have always been able to optimize the R code itself to get it
> to run sufficiently fast for my purposes.

The nice thing about being able to use C code is that this provides confidence 
that however slowly your R script runs right now you will be able to make it 
faster - no matter what.

On quite a few occasions I have started writing C code and after thinking 
about how I would structure it realized that I can do the same thing in R and 
still get 50% of the speed improvement I get from C.

Also, I am not sure whether this is mentioned anywhere, but I found it to be 
more convenient to use dyn.load directly instead of creating a full-blown R 
package. This way the edit-compile-test cycle is much more convenient.


                                   Vladimir Dergachev

More information about the R-devel mailing list