Re: [R] Efficiency Question - Nested lapply or nested for loop

2010-10-11 Thread epowell
Thank you both for your advice. I ended up implementing both solutions and testing them on a real dataset of 10,000 rows and 50 inds. The results are very, very interesting. For some context, the original two approaches, nested lapply and nested for loops, performed at 1.501529 and 1.458963 mi

Re: [R] Efficiency Question - Nested lapply or nested for loop

2010-10-08 Thread Gabor Grothendieck
On Fri, Oct 8, 2010 at 12:47 PM, Gabor Grothendieck wrote: > On Fri, Oct 8, 2010 at 11:35 AM, epowell wrote: >> >> My data looks like this: >> >>> data >>  name G_hat_0_0 G_hat_1_0 G_hat_2_0 G_0 G_hat_0_1 G_hat_1_1 G_hat_2_1 G_1 >> 1  rs0  0.488000  0.448625  0.063375   1  0.480875  0.454500  0.0

Re: [R] Efficiency Question - Nested lapply or nested for loop

2010-10-08 Thread Gabor Grothendieck
On Fri, Oct 8, 2010 at 11:35 AM, epowell wrote: > > My data looks like this: > >> data >  name G_hat_0_0 G_hat_1_0 G_hat_2_0 G_0 G_hat_0_1 G_hat_1_1 G_hat_2_1 G_1 > 1  rs0  0.488000  0.448625  0.063375   1  0.480875  0.454500  0.064625   1 > 2  rs1  0.002375  0.955375  0.042250   1  0.00  0.06

Re: [R] Efficiency Question - Nested lapply or nested for loop

2010-10-08 Thread David Winsemius
You are loosing a lot of time by repeatedly calculating character indices with paste() in every iteration. Two options: -- 1) calculate these once outside the loop and then refer to them by index idx.names <- vector(mode="character", length=nind) for (i in (0:(nind-1))) {idx[i+1] <-# ne

[R] Efficiency Question - Nested lapply or nested for loop

2010-10-08 Thread epowell
My data looks like this: > data name G_hat_0_0 G_hat_1_0 G_hat_2_0 G_0 G_hat_0_1 G_hat_1_1 G_hat_2_1 G_1 1 rs0 0.488000 0.448625 0.063375 1 0.480875 0.454500 0.064625 1 2 rs1 0.002375 0.955375 0.042250 1 0.00 0.062875 0.937125 2 3 rs2 0.050375 0.835875 0.113750