Re: [S] while

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


try:

tox <- matrix(0,20, 20)
for(i in 1:20) for(j in 1:20) tox[i,j] <- "my calculation"

In jeneral while takes more time than for, so it is nor recomended,
unless you have to.

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