Re: [R] for loop error

From: ecoinfo <ecoinformatics_at_gmail.com>
Date: Fri 23 Dec 2005 - 23:22:54 EST

I guess you missed {} after for ():

       for (j in 1:groups)                     # no.groups=50
## ?? for (j in 1:groups) {

               for (k in 1:length(ratio)) ## ?? for () {

On 12/23/05, Ita.Cirovic-Donev@hypo-alpe-adria.com <Ita.Cirovic-Donev@hypo-alpe-adria.com> wrote:
>
>
>
>
> 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
>
> ______________________________________________
> 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
>

--
Xiaohua Dai, Dr.

______________________________________________
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 23:36:02 2005

This archive was generated by hypermail 2.1.8 : Sat 24 Dec 2005 - 02:31:22 EST