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 >5Thanks in advance, Martin
> 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
for (i in 1:5) {print(i)} Cheers Iain --- Martin Lam <tmlammail at yahoo.com> wrote:> 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 >
Hi, > -----Original Message-----> From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Martin Lam > > 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 > } >yes, should be possible: for (i in 1:5) { print(i) } It might also help (assuming you work on MS Windows using RGui.exe) to disable "buffered output" by pressing "CTRL+W". As you can see when clicking on "Misc" in the toolbar, the default setting is "buffered output". I hope this helps, Roland +++++ This mail has been sent through the MPI for Demographic Rese...{{dropped}}