[R] for loop error

Ita.Cirovic-Donev@hypo-alpe-adria.com Ita.Cirovic-Donev at hypo-alpe-adria.com
Fri Dec 23 11:39:51 CET 2005





I have the following code and I am not sure what's wrong or how to make it
work.

B <- matrix(1,nrow=50,ncol=2)
for (i in 1:length(size.out)){                  # length(size.out=2) these
are the two variables
    X <- var.range[i,1]                         #  min
    Y <- var.range[i,1]                         # min
    ratio <- size.out[,i]
        for (j in 1:groups)                     # no.groups=50
            A <- 0
            X <- Y                               # min
            Y <- X + span.group.size[i,1]             # min + (max-min)/50
                for (k in 1:length(ratio))                  # there are
11065 observations per variable
                    if ((X <= ratio[k]) & (ratio[k] >= Y))
                        A <- A+1
                        B[j,i] <- A
                        print(B)
     }

basically, what I want to do is obtain a range for the variables in
size.out data frame. I do this by computing min and max and getting a span.
Then I have

var.range is defined by row=variables from size.out and col=[min max]
span.group.size is defined as row=variables from size.out and col=[span]

Now I want to count how many values fall into defined range with if ((X <=
ratio[k]) & (ratio[k] >= Y)). This count I need to store which I then later
on plot.

Thanks.
____________________
Ita Cirovic-Donev




More information about the R-help mailing list