[R] An "R is slow"-article

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Wed Jan 9 17:14:04 CET 2008

Gustaf Rydevik wrote:
> Hi all,
> Reading the wikipedia page on R, I stumbled across the following:
> http://fluff.info/blog/arch/00000172.htm
> It does seem interesting that the C execution is that much slower from
> R than from a native C program. Could any of the more technically
> knowledgeable people explain why this is so?
Well, if you are obsessed with speed, R can be the wrong tool. This is
an ingrained aspect of the language itself; if you are interested,
consult some of Luke Tierney's writings about the difficulties of
writing an R compiler. To some extent, it is a tradeoff for flexibility
and expressiveness.

The example is somewhat misleading. The C execution time is probably the
same, but it is drowned out by the administrative overhead of
fisher.test (a 2x2 Fisher test is really not a very complex operation
when cell counts are in the hundreds.)

> The author also have some thought-provoking opinions on R being
> no-good and that you should write everything in C instead (mainly
> because R is slow and too good at graphics, encouraging data
> snooping). See  http://fluff.info/blog/arch/00000041.htm
>  While I don't agree (granted, I can't really write C), it was
> interesting to read something from a very different perspective than
> I'm used to.
The idea that you really shouldn't look at data before testing
statistical hypotheses is not without merit, but taken to the extreme,
it tends to become ridiculous. You end up in a situation where you
either can't do anything or you don't know what you are doing. It is
related to the discussions about randomized trials versus observational
studies. The former are in many ways stronger, but sometimes
unavailable, and they tend to be using a very big hammer to whack in a
single nail.

   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907

More information about the R-help mailing list