Re: [R] help to speed up loops in r

2009-06-09 Thread Jeremiah Rounds
time it is absolute essential to use the right data structure for the job. Hope this is of assistance, Jeremiah Rounds > Date: Mon, 8 Jun 2009 15:45:40 +0000 > From: amitrh...@yahoo.co.uk > To: r-help@r-project.org > Subject: [R] help to speed up loops in r > > >

Re: [R] help to speed up loops in r

2009-06-08 Thread Bert Gunter
Bert Gunter Genentech nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jorge Ivan Velez Sent: Monday, June 08, 2009 9:03 AM To: Amit Patel Cc: r-help@r-project.org Subject: Re: [R] help to speed up loop

Re: [R] help to speed up loops in r

2009-06-08 Thread Jorge Ivan Velez
Dear Amit, The following should get you started: # Some data set.seed(123) X <- matrix(rnorm(20*10), ncol=10) X # Group of replicates g <- rep(1:(ncol(X)/2), each=2) g # Mean of replicate variables t(apply(X, 1, tapply, g, mean, na.rm = TRUE)) I created a grouping variable (g) and then calculat

[R] help to speed up loops in r

2009-06-08 Thread Amit Patel
Hi i am using a script which involves the following loop. It attempts to reduce a data frame(zz) of 95000 * 41 down to a data frame (averagedreplicates) of 95000 * 21 by averaging the replicate values as you can see in the script below. This script however is very slow (2days). Any suggestions