Hi, Suppose I have: for(i in 1:100000) rnorm(100000) (just a fake example, as my actual example is too long) Is it possible to get the loop to print out i each time it has run? Something like: for(i in 1:100000) { print(i) rnorm(100000) } will only print i after the loop is completed. But if I want to print out i whenever it re-enters the loop, is it possible (so I know how many times the loop has been run)? Cheers, Kevin -------------------------------- Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301
Kevin Wang <Kevin.Wang at maths.anu.edu.au> writes:> Hi, > > Suppose I have: > for(i in 1:100000) > rnorm(100000) > (just a fake example, as my actual example is too long) > > Is it possible to get the loop to print out i each time it has run? > Something like: > for(i in 1:100000) { > print(i) > rnorm(100000) > } > will only print i after the loop is completed. But if I want to print out > i whenever it re-enters the loop, is it possible (so I know how many times > the loop has been run)?Kevin, you must have seen this on the list before! Either use flush.console() or turn off the output buffering (Windows FAQ 6.3). -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Hi, On Thu, 4 Nov 2004, Peter Dalgaard wrote:> Kevin, you must have seen this on the list before! Either use > flush.console() or turn off the output buffering (Windows FAQ 6.3).Whoopss....sorry, I must be tired....need another cup of coffee. Kev -------------------------------- Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7407 Ph (M): +61-40-451-8301
Kevin Wang wrote:> Hi, > > Suppose I have: > for(i in 1:100000) > rnorm(100000) > (just a fake example, as my actual example is too long) > > Is it possible to get the loop to print out i each time it has run? > Something like: > for(i in 1:100000) { > print(i) > rnorm(100000) > } > will only print i after the loop is completed. But if I want to print out > i whenever it re-enters the loop, is it possible (so I know how many times > the loop has been run)?Kevin, you know that all people are asked to read the FAQs (in particlular the R for Windows FAQs in this case - regarding buffered output!) before asking questions on R-help ... Uwe>> Cheers, > > Kevin > > -------------------------------- > Ko-Kang Kevin Wang > PhD Student > Centre for Mathematics and its Applications > Building 27, Room 1004 > Mathematical Sciences Institute (MSI) > Australian National University > Canberra, ACT 0200 > Australia > > Homepage: http://wwwmaths.anu.edu.au/~wangk/ > Ph (W): +61-2-6125-2431 > Ph (H): +61-2-6125-7407 > Ph (M): +61-40-451-8301 > > ______________________________________________ > 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