From: Petr Pikal <petr.pikal_at_precheza.cz>

Date: Fri 23 Dec 2005 - 22:17:23 EST

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 22:25:30 2005

Date: Fri 23 Dec 2005 - 22:17:23 EST

Hi

As we do not have your data and you did not specify what is wrong and
your code is a bit messy I can not reproduce what you did and failed
to do.

In each email there is statement

> PLEASE do read the posting guide!

*> http://www.R-project.org/posting-guide.html
*

You probably should look at

range? and apply?

> apply(barva[,4:21], 2, function(x) sum((x<5)& (x>0), na.rm=T))

tuny fe2o3 vlhk vodos vodiv ph zba zbb olej dispRD pod1mi tio2 l a b ce h DEcmc 1 0 548 548 0 75 548 0 0 0 11 63 0 0 0 0 0 548

gives me number of values in data frame barva in <0,5> interval, if this is what you want.

**HTH
**

Petr

On 23 Dec 2005 at 11:45, Ita.Cirovic-Donev@hypo-alpe-a wrote:

To: r-help@stat.math.ethz.ch From: Ita.Cirovic-Donev@hypo-alpe-adria.com Date sent: Fri, 23 Dec 2005 11:45:02 +0100 Subject: [R] for loop error

*>
**>
**>
**>
**>
*

> 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
*

Petr Pikal

petr.pikal@precheza.cz

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 22:25:30 2005

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