Re: [R] How to speed up multiple for loop over list of data frames

2007-10-18 Thread Gavin Simpson
On Wed, 2007-10-17 at 19:57 -0600, James wrote: > On Oct 17, 2007, at 4:36 PM, James wrote: > > > On Oct 17, 2007, at 10:18 AM, Waterman, DG ((David)) wrote: > > > >> I agree. Avoid the lines like: > >> iv = c( iv, min(i, j) ) > >> > >> I had code that was sped up by 70 times after fixing the

Re: [R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread James
On Oct 17, 2007, at 4:36 PM, James wrote: > On Oct 17, 2007, at 10:18 AM, Waterman, DG ((David)) wrote: > >> I agree. Avoid the lines like: >> iv = c( iv, min(i, j) ) >> >> I had code that was sped up by 70 times after fixing the size of my >> output object before entering a loop. > > I'm in t

Re: [R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread James
On Oct 17, 2007, at 10:18 AM, Waterman, DG ((David)) wrote: > I agree. Avoid the lines like: > iv = c( iv, min(i, j) ) > > I had code that was sped up by 70 times after fixing the size of my > output object before entering a loop. I'm in the process of replacing that very kind of command. In

Re: [R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread Bartjoosen
Maybe I'm wrong, but aren't you calculating just the same as cor(data frame,method ="spearman"), with some further parameters being monitored? Could you please provide a commented, minimal, self-contained, reproducible code, so that we can see what is actually going on and what is the way you wa

Re: [R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread Bert Gunter
PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Waterman, DG (David) Sent: Wednesday, October 17, 2007 9:18 AM To: Dieter Best Cc: r-help@r-project.org Subject: Re: [R] How to speed up multiple for loop over list of data frames I agree. Avoid the lines like: iv = c( iv, min(i, j) ) I had co

Re: [R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread Waterman, DG (David)
October 2007 15:57 To: jim holtman Cc: r-help@r-project.org; Dieter Best Subject: Re: [R] How to speed up multiple for loop over list of data frames I suspect the vast majority of time is because of growing objects. Preallocate 'iv', 'jv', 'rho_sv' and 'rho_pv

Re: [R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread Patrick Burns
I suspect the vast majority of time is because of growing objects. Preallocate 'iv', 'jv', 'rho_sv' and 'rho_pv' to be their final length and then subscript into them with their values. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide f

Re: [R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread jim holtman
First thing to do is to use Rprof (?Rprof) on a subset of your data to see where time is being spent. My guess is that most of it is in the calls to 'cor' and if this is the case, they you have to figure out some other algorithm. Also if these dataframes all contain numeric information, convert t

[R] How to speed up multiple for loop over list of data frames

2007-10-17 Thread Dieter Best
Hi there, I have a multiple for loop over a list of data frames for ( i in 1:(N-1) ) { for ( j in (i+1):N ) { for ( p in 1:M ) { v_i[p]= alist[[p]][i,"v"] v_j[p]= alist[[p]][j,"v"] } rho_s = cor(v_i, v_j, method =