Re: [R] nested 'while' loops

2013-03-25 Thread Patrick Burns
Your immediate problem is that 'y' is not reset to 1. Easier code to write would be to use 'for' loops rather than 'while' loops. Better still would be to use neither if possible. I suspect that you are in Circle 3 of 'The R Inferno'. http://www.burns-stat.com/documents/books/the-r-inferno/ P

Re: [R] nested 'while' loops

2013-03-25 Thread Sahana Srinivasan
while(x<=21) { while(y<=rown) { n<-as.numeric(df[[y]][x]); if(n>0) { while(k<=lim) { k<-k+1; } # while loop for k closes opdf[[y]][x]<-sum; } # if statement closes y<-y+1; } #while for y closes x<-x+1; } #while wi

Re: [R] nested 'while' loops

2013-03-25 Thread Berend Hasselman
On 25-03-2013, at 18:43, Sahana Srinivasan wrote: > Hi everyone, > I'm using the following code to go over every element of a data frame (row > wise). The problem I am facing is that the outer 'x' variable is not > incrementing itself, thus, only one row of values is obtained, and the > program

Re: [R] nested 'while' loops

2013-03-25 Thread Sahana Srinivasan
Hi, sorry that got sent without the output : Please ignore the aligning in the input, I am re-adding that here as well : 1GENEACDEFGHIKLMNPQRSTVWY2amt:Amet_00012902334171612422939635201325342732312 3amt:Amet_000219315421218835254372613914212030084 Output: 1GENEACDEFGHIKLMNPQRSTVWY2amt:Amet_00010.8

[R] nested 'while' loops

2013-03-25 Thread Sahana Srinivasan
Hi everyone, I'm using the following code to go over every element of a data frame (row wise). The problem I am facing is that the outer 'x' variable is not incrementing itself, thus, only one row of values is obtained, and the program does not proceed to the next row. This is the code: while(x<=