Re: [S] while

Kutsyy (kutsyy@umich.edu)
Thu, 05 Feb 1998 16:16:54 -0500


Sorry for second message, but forgot to explai error.

This would worklike:
tox <- matrix(0,20, 20)
j <- 1
while(j <= 20){
i<-1
while(i <=20){
tox[i,j] <- "my calculation"
i <- i +1}
j <- j+1}

Note you have to make i=1 each time you want to run while(i<=20),
otherway it will not enter second loop.

PS: Use for() not while.

David Wang wrote:
>
> Dear S+ users,
>
> I wrote a program to update the values of a matrix by using
> two while statement. But the outer loop does not change and stay at the initial
> value.
>
> Thank you for any comments or suggestion.
>
> The program follows:
> tox <- matrix(0,20, 20)
> i <- 1
> j<-1
> while(j <= 20){
> while(i <=20){
> tox[i,j] <- "my calculation"
> i <- i +1}
> j <- j+1}
>
> Note: the j loop just goes 1 time.
>
> David
> -----------------------------------------------------------------------
> This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> message: unsubscribe s-news

-- 
Vadim Kutsyy
kutsyy@umich.edu
http://www.stat.lsa.umich.edu/~kutsyy
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news