[R] for loop error

From: <Ita.Cirovic-Donev_at_hypo-alpe-adria.com>
Date: Fri 23 Dec 2005 - 21:45:02 EST

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

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.


Ita Cirovic-Donev

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Dec 23 21:59:12 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:40 EST