I'm a new user and am having trouble with loops.
In the following, I'm trying to add the results of "test" and the loops are
not working.
I've simplified the loop.  What am I doing wrong?
Thanks!
> test<-numeric(20)
> tot<-numeric(20)
> for(i in 1:20){test[i]<-1}
> for (i in 1:20){tot[i]<-(test[i]+tot[i])}
> tot
 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to