Sorry, I forgot to correct the message subject, so I am resending my
doubt it below:
Hi all!
I wrote a very basic program in R, which has some loops ('for' and
'while'). Is there a way to print the 'for' (or while) indice while the
program is running so that I am able to estimate where the program is
and how long it will last?
I mean, I want something like this:
i<-0
While(i<100){
"do a lot of commands"
"print i"
i<-i+1
}
How do I "print" the "i" at each step?
Thanks in advance,
Marcos
Printting 'for' and 'while' indices
7 messages · Marcos Sanches, Jeff Gentry, Andy Bunn +4 more
How do I "print" the "i" at each step?
print(i)?
Use cat() or print(). -roger
Marcos Sanches wrote:
Sorry, I forgot to correct the message subject, so I am resending my
doubt it below:
Hi all!
I wrote a very basic program in R, which has some loops ('for' and
'while'). Is there a way to print the 'for' (or while) indice while the
program is running so that I am able to estimate where the program is
and how long it will last?
I mean, I want something like this:
i<-0
While(i<100){
"do a lot of commands"
"print i"
i<-i+1
}
How do I "print" the "i" at each step?
Thanks in advance,
Marcos
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Consider the following:
> i <- 0
> while(i < 5) {
"do stuff"
print(i)
i <- i + 1
}
[1] 0
[1] 1
[1] 2
[1] 3
[1] 4
> i <- 0
> while(i < 5) {
"do stuff"
cat(i, "")
i <- i + 1
}
0 1 2 3 4 > i <- 0
> while(i < 100) {
"do stuff"
if((i %% 10) == 0)
cat(i, "")
i <- i + 1
}
0 10 20 30 40 50 60 70 80 90
This was produced in S-Plus 6.2 under Windows 2000. For some
reason, when I copy this code from S-Plus to R1.8.1 via XEmacs, this is
locking up R for me right now, and I can't figure out why. However, I
see no reason why these constructs would not work in R.
hope this helps.
spencer graves
Marcos Sanches wrote:
Sorry, I forgot to correct the message subject, so I am resending my
doubt it below:
Hi all!
I wrote a very basic program in R, which has some loops ('for' and
'while'). Is there a way to print the 'for' (or while) indice while the
program is running so that I am able to estimate where the program is
and how long it will last?
I mean, I want something like this:
i<-0
While(i<100){
"do a lot of commands"
"print i"
i<-i+1
}
How do I "print" the "i" at each step?
Thanks in advance,
Marcos
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Quoting Marcos Sanches <marcos.sanches at ipsos-opinion.com.br>:
I mean, I want something like this:
i<-0
While(i<100){
"do a lot of commands"
"print i"
i<-i+1
}
How do I "print" the "i" at each step?
Is print(i) what you want? Cheers, Kevin ------------------------------------------------------------ Ko-Kang Kevin Wang SLC Statistics Workshops Co-ordinator Student Learning Centre University of Auckland New Zealand ------------------------------------------------- This mail sent through University of Auckland http://www.auckland.ac.nz/
Hmm, maybe you mean that you've got problems with buffered output when using Rgui under Windows? If so, turn it off by the "Misc | Buffered Output (Ctrl+W)" menu item. Henrik Bengtsson
-----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Jeff Gentry Sent: den 9 februari 2004 20:49 To: Marcos Sanches Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Printting 'for' and 'while' indices
How do I "print" the "i" at each step?
print(i)?
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailma> n/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html