[R] Compilation of R code
Spencer Graves
spencer.graves at pdf.com
Fri Jan 7 18:48:59 CET 2005
R is basically an interpreted language. To my knowledge, the
standard approach to improving speed starts by finding which steps take
the most time. This can be done using "proc.time" and / or
"system.time" (preceded by "gc" to clean things up so the timing is more
stable).
Once you've determined which loop or function call consumes the
most time, you then need to decide what to do about it. R is
vectorized, so if you use loops like in Fortran or C, you might be able
to replace complicated pieces of code with one or only a very few
commands. This list has considered many questions about speed, so once
you know which steps are taking the most time, you can search the
archives as described in the posting guide,
"http://www.R-project.org/posting-guide.html". If that does not solve
the problem, you can translate a function into a compiled language like
C. See help.start() -> "Writing R Extensions" -> "System and foreign
language interfaces".
hope this helps.
spencer graves
Depire Alexandre wrote:
>Hello,
>I'm a newbie on this list.
>I have a R code but its execution take a very long time.
>Is it possible to compile it (in C for example) to decrease the execution
>time ?
>
>
>
More information about the R-help
mailing list