[R] nested 'while' loops
Berend Hasselman
bhh at xs4all.nl
Mon Mar 25 18:55:16 CET 2013
On 25-03-2013, at 18:43, Sahana Srinivasan <sahanasrinivasan.91 at gmail.com> 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 does not proceed to the next row.
>
> This is the code:
> while(x<=coln)
> {
>
> while(y<=rown)
> {
> n<-as.numeric(df[[y]][x]);
> if(n>0)
> {
> lim<-(n-1);
> S<-100;
> (...)
> }
> opdf[[y]][x]<-sum;
> }
> y<-y+1;
> }
> x<-x+1;
> }
>
> Here is a sample of the input data:
>
>
> GENE A CD EF GH IK LM NP QR ST VW Y 2amt:Amet_0001 29 023 3417 1612 4229 39635
> 20 1325 3427 323 12 3amt:Amet_0002 19 315 4212 188 3525 437 2613 914 2120 30
> 0 8
This does not provide reproducible code or an example.
You should also count the opening { and the closing }.
Berend
More information about the R-help
mailing list