I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute?
pause in function execution
11 messages · Fuchs Ira, Andrew, Duncan Murdoch +2 more
I am not too sure what your question is, but try ?debug or take a look at http://www.ats.ucla.edu/stat/r/library/R-debug-tools.pdf
On Feb 10, 9:07?am, Fuchs Ira <irafu... at gmail.com> wrote:
I would like to have a function which gets data, does a calculation ? and prints a result and then waits some number of seconds and ? repeats. ?If I use Sys.sleep, the execution is pausing but the ? function output is buffered so that it all comes out when the function ? terminates. ?How can I get output while the function continues to ? execute?
______________________________________________ R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 09/02/2009 5:07 PM, Fuchs Ira wrote:
I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute?
Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. Duncan Murdoch
Yes, Windows has that in the Misc menu, but I don't see a way to do this on the Mac.
On Feb 9, 2009, at 5:51 PM, Duncan Murdoch wrote:
On 09/02/2009 5:07 PM, Fuchs Ira wrote:
I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute?
Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. Duncan Murdoch
On 10/02/2009, at 12:09 PM, Fuchs Ira wrote:
Yes, Windows has that in the Misc menu, but I don't see a way to do this on the Mac.
In my experience output is not buffered on a Mac. Are you actually *printing* out the results you want to see? Could you, as the posting guide requests, provide a minimal self-contained example? cheers, Rolf Turner
On Feb 9, 2009, at 5:51 PM, Duncan Murdoch wrote:
On 09/02/2009 5:07 PM, Fuchs Ira wrote:
I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute?
Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. Duncan Murdoch
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
Have you tried flush.console() ? r ------------------------------------------------- Remko Duursma Post-Doctoral Fellow Centre for Plant and Food Science University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908
On Tue, Feb 10, 2009 at 10:21 AM, Rolf Turner <r.turner at auckland.ac.nz> wrote:
On 10/02/2009, at 12:09 PM, Fuchs Ira wrote:
Yes, Windows has that in the Misc menu, but I don't see a way to do this on the Mac.
In my experience output is not buffered on a Mac.
Are you actually *printing* out the results you want to see?
Could you, as the posting guide requests, provide a minimal
self-contained example?
cheers,
Rolf Turner
On Feb 9, 2009, at 5:51 PM, Duncan Murdoch wrote:
On 09/02/2009 5:07 PM, Fuchs Ira wrote:
I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute?
Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. Duncan Murdoch
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
______________________________________________ R-help at 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090209/fac7f8ba/attachment-0001.pl>
On 10/02/2009, at 12:09 PM, Fuchs Ira wrote:
Yes, Windows has that in the Misc menu, but I don't see a way to do this on the Mac.
In my experience output is not buffered on a Mac. Are you sure you're *printing* the output you want to see? Can you provide, as the posting guide requests, minimal self-contained code? cheers, Rolf Turner
On Feb 9, 2009, at 5:51 PM, Duncan Murdoch wrote:
On 09/02/2009 5:07 PM, Fuchs Ira wrote:
I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute?
Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. Duncan Murdoch
______________________________________________ R-help at 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.
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
On 09/02/2009 6:27 PM, Fuchs Ira wrote:
a=function() {
print("start")
print(Sys.time())
Sys.sleep(5)
print(Sys.time())
print("end") }
a()
results in:
[1] "start"
[1] "2009-02-09 18:25:41 EST"
[1] "2009-02-09 18:25:46 EST"
[1] "end"
all printed together after 5 seconds.
The reason for this mysterious difference is presumably that you are not using the same front-end as Rolf, or maybe not the same version as him, or maybe you have the buffering set differently. sessionInfo() would remove some of the mystery, but I don't think it says which Mac front end you're using. We should fix that. (It's not just a Mac deficiency, Windows has the same omission.) Duncan Murdoch
On Feb 9, 2009, at 6:21 PM, Rolf Turner wrote:
On 10/02/2009, at 12:09 PM, Fuchs Ira wrote:
Yes, Windows has that in the Misc menu, but I don't see a way to do this on the Mac.
In my experience output is not buffered on a Mac.
Are you actually *printing* out the results you want to see?
Could you, as the posting guide requests, provide a minimal
self-contained example?
cheers,
Rolf Turner
On Feb 9, 2009, at 5:51 PM, Duncan Murdoch wrote:
On 09/02/2009 5:07 PM, Fuchs Ira wrote:
I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is
pausing
but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute?
Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. Duncan Murdoch
###################################################################### Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.com ######################################################################
[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
On 10/02/2009, at 12:55 PM, Duncan Murdoch wrote:
On 09/02/2009 6:27 PM, Fuchs Ira wrote:
a=function() {
print("start")
print(Sys.time())
Sys.sleep(5)
print(Sys.time())
print("end") }
a()
results in:
[1] "start"
[1] "2009-02-09 18:25:41 EST"
[1] "2009-02-09 18:25:46 EST"
[1] "end"
all printed together after 5 seconds.
The reason for this mysterious difference is presumably that you are not using the same front-end as Rolf, or maybe not the same version as him, or maybe you have the buffering set differently. sessionInfo() would remove some of the mystery, but I don't think it says which Mac front end you're using. We should fix that. (It's not just a Mac deficiency, Windows has the same omission.)
Looking at the code of flush.console() (suggested by Remko Duursma)
solved the mystery. It refers to the AQUA GUI. I don't use the
GUI as a rule; I start R from the command line.
When I started R from the GUI I got the same buffered phenomenon
that afflicted Ira Fuchs. So one solution to his problem would
presumably be to start R from the command line rather than by
clicking on the GUI.
There must be a way to switch off buffering when using the AQUA GUI
though. Mustn't there?
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
The binary in R.app starts the GUI. I suppose I would have to install the command-line version separately.
On Feb 9, 2009, at 7:12 PM, Rolf Turner wrote:
On 10/02/2009, at 12:55 PM, Duncan Murdoch wrote:
On 09/02/2009 6:27 PM, Fuchs Ira wrote:
a=function() {
print("start")
print(Sys.time())
Sys.sleep(5)
print(Sys.time())
print("end") }
a()
results in:
[1] "start"
[1] "2009-02-09 18:25:41 EST"
[1] "2009-02-09 18:25:46 EST"
[1] "end"
all printed together after 5 seconds.
The reason for this mysterious difference is presumably that you are not using the same front-end as Rolf, or maybe not the same version as him, or maybe you have the buffering set differently. sessionInfo() would remove some of the mystery, but I don't think it says which Mac front end you're using. We should fix that. (It's not just a Mac deficiency, Windows has the same omission.)
Looking at the code of flush.console() (suggested by Remko Duursma) solved the mystery. It refers to the AQUA GUI. I don't use the GUI as a rule; I start R from the command line. When I started R from the GUI I got the same buffered phenomenon that afflicted Ira Fuchs. So one solution to his problem would presumably be to start R from the command line rather than by clicking on the GUI. There must be a way to switch off buffering when using the AQUA GUI though. Mustn't there? cheers, Rolf Turner ###################################################################### Attention:This e-mail message is privileged and confidential. If you are not theintended recipient please delete the message and notify the sender.Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshalwww.marshalsoftware.com ######################################################################