[R] How to print output during for loops?

ronggui 042045003 at fudan.edu.cn
Sat Oct 29 13:16:30 CEST 2005


> for (i in 1:5) {
+ cat(paste(i,"\n"))
+ }
1 
2 
3 
4 
5 
> for (i in 1:5) {
+ print(i)
+ }
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
	

======= 2005-10-29 18:03:13 ÄúÔÚÀ´ÐÅÖÐÐ´µÀ£º=======

>Hi,
>
>I was wondering, if it is possible to print out the
>values of variables while you are in a for/while loop?
>Like this for example:
>  
>for (i in 1:5) {
>  i
>}
>
>So what I want is this as output in the console:
>>1
>>2
>>3
>>4
>>5
>
>Thanks in advance,
>
>Martin
>
>______________________________________________
>R-help at 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

= = = = = = = = = = = = = = = = = = = =
			


 

2005-10-29

------
Deparment of Sociology
Fudan University

My new mail addres is ronggui.huang at gmail.com
Blog:http://sociology.yculblog.com




More information about the R-help mailing list