Re: [R] Speed Advice for R --- avoid data frames

2011-07-06 Thread Frank Harrell
On occasion, as pointed out in an earlier posting, it is efficient to convert to a matrix and when finished convert back to a data frame. The Hmisc package's asNumericMatrix and matrix2dataFrame functions assist by converting character variables to factors if needed, and by holding on to original

Re: [R] Speed Advice for R --- avoid data frames

2011-07-03 Thread Uwe Ligges
On 02.07.2011 21:35, ivo welch wrote: hi uwe---thanks for the clarification. of course, my example should always be done in vectorized form. I only used it to show how iterative access compares in the simplest possible fashion.<100 accesses per seconds is REALLY slow, though. I don't know R

Re: [R] Speed Advice for R --- avoid data frames

2011-07-02 Thread ivo welch
hi uwe---thanks for the clarification. of course, my example should always be done in vectorized form. I only used it to show how iterative access compares in the simplest possible fashion. <100 accesses per seconds is REALLY slow, though. I don't know R internals and the learning curve would b

Re: [R] Speed Advice for R --- avoid data frames

2011-07-02 Thread Uwe Ligges
Some comments: the comparison matrix rows vs. matrix columns is incorrect: Note that R has lazy evaluation, hence you construct your matrix in the timing for the rows and it is already constructed in the timing for the columns, hence you want to use: M <- matrix( rnorm(C*R), nrow=R ) D <-

[R] Speed Advice for R --- avoid data frames

2011-07-02 Thread ivo welch
This email is intended for R users that are not that familiar with R internals and are searching google about how to speed up R. Despite common misperception, R is not slow when it comes to iterative access. R is fast when it comes to matrices. R is very slow when it comes to iterative access in