Message-ID: <4354ECFB.8010504@stats.uwo.ca>
Date: 2005-10-18T12:39:23Z
From: Duncan Murdoch
Subject: How to speed up R code?
In-Reply-To: <20051018122158.21583.qmail@web40522.mail.yahoo.com>
Martin Lam wrote:
> 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?
One piece of advice I forgot to give to Xiaohua: try it! You can
probably write slow code using *either* matrices or lists. You need to
identify what is slow, and fix it.
Duncan Murdoch