[R] While loop

Rheannon rbrooks at uvic.ca
Fri Jul 11 19:06:34 CEST 2008


Hello,

I am trying to loop through a matrix column and find the first value <=0 and
store that matrix location in a variable called Start.

I have tried the following:
i <- 1
j <- 1
while (Matrix[i, j] > 0)
i = (i + 1)
#loop until matrix [i, j] value <= 0
#strore that row number in a variable
Start <- i

I am getting a scripting out of bounds error and I suspect maybe the loop
isnt stoping at the end of the matrix? 

Any help is greatly appreciated!
Cheers,
Rheannon

-- 
View this message in context: http://www.nabble.com/While-loop-tp18408462p18408462.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list