Re: [R] Trying to avoid nested loop

2013-10-04 Thread arun
lippe massicotte To: "r-help@r-project.org" Cc: Sent: Friday, October 4, 2013 9:49 AM Subject: [R] Trying to avoid nested loop Dear R users. I'm trying to avoid using nested loops in the following code but I'm not sure how to proceed. Any help would be greatly appreciated.

Re: [R] Trying to avoid nested loop

2013-10-04 Thread arun
philippe massicotte To: "r-help@r-project.org" Cc: Sent: Friday, October 4, 2013 9:49 AM Subject: [R] Trying to avoid nested loop Dear R users. I'm trying to avoid using nested loops in the following code but I'm not sure how to proceed. Any help would be greatly appreci

Re: [R] Trying to avoid nested loop

2013-10-04 Thread philippe massicotte
Thank you for your answer. This is what I needed. > From: s.elli...@lgcgroup.com > To: r-help@r-project.org > Date: Fri, 4 Oct 2013 15:13:49 +0100 > Subject: Re: [R] Trying to avoid nested loop > > > > I'm trying to avoid using nested loops in the following cod

Re: [R] Trying to avoid nested loop

2013-10-04 Thread S Ellison
> I'm trying to avoid using nested loops in the following code but I'm > not sure how to proceed. Any help would be greatly appreciated. > With regards,Phil > X = matrix(rnorm(100), 10, 10) > result = 0 > for(m in 1:nrow(X)){ > for(n in 1:ncol(X)){ > if(X[m,n] != 0){

[R] Trying to avoid nested loop

2013-10-04 Thread philippe massicotte
Dear R users. I'm trying to avoid using nested loops in the following code but I'm not sure how to proceed. Any help would be greatly appreciated. With regards,Phil X = matrix(rnorm(100), 10, 10) ## Version with nested loopsresult = 0 for(m in 1:nrow(X)){ for(n in 1:ncol(X)){if(X[m,n] !=