Re: [R] Fastest Way to Divide Elements of Row With Its RowSum

2009-09-17 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Lumley > Sent: Thursday, September 17, 2009 6:59 AM > To: William Revelle > Cc: r-h...@stat.math.ethz.ch > Subject: Re: [R] Fastest Way to Divide Ele

Re: [R] Fastest Way to Divide Elements of Row With Its RowSum

2009-09-17 Thread Thomas Lumley
On Thu, 17 Sep 2009, William Revelle wrote: At 2:40 PM +0900 9/17/09, Gundala Viswanath wrote: I have a data frame (dat). What I want to do is for each row, divide each row with the sum of its row. The number of row can be large > 1million. Is there a faster way than doing it this way? datno

Re: [R] Fastest Way to Divide Elements of Row With Its RowSum

2009-09-16 Thread William Revelle
At 2:40 PM +0900 9/17/09, Gundala Viswanath wrote: I have a data frame (dat). What I want to do is for each row, divide each row with the sum of its row. The number of row can be large > 1million. Is there a faster way than doing it this way? datnorm; for (rw in 1:length(dat)) { tmp <- dat

[R] Fastest Way to Divide Elements of Row With Its RowSum

2009-09-16 Thread Gundala Viswanath
I have a data frame (dat). What I want to do is for each row, divide each row with the sum of its row. The number of row can be large > 1million. Is there a faster way than doing it this way? datnorm; for (rw in 1:length(dat)) { tmp <- dat[rw,]/sum(dat[rw,]) datnorm <- rbind(datnorm, tmp