[R] How to speed up R code?

Martin Lam tmlammail at yahoo.com
Tue Oct 18 14:21:58 CEST 2005


Hi,

I have written a piece of code, which is a variant of
the random forest (rf) package algorithm, entirely in
R. I know that some of the code in the rf package is
written in c or c++. The problem is that the execution
of my code in R takes a lot of time. To give you an
example, the building and testing of data set with
20,000 instances using the random forest function from
the rf package takes a few minutes while 'my' random
forest's execution time is around 5 hours. So, I
wonder if there are some ways to speed up the
execution time. 

I've read in a similar post that using matrix instead
of data.frame would actually speed up the R code. The
format of my read-in data set is a "list", would the
data set in matrix format (using as.matrix) be better?

Thanks in advance,

Martin




More information about the R-help mailing list