1

Possible Duplicate:
Is there a way to make R beep/play a sound at the end of a script?

While waiting for R to finish a 5-10 minute job, I might start writing (at best), although I would like to get back to the analysis promptly upon completion.

What options do I have to be notified when R completes an analysis on localhost?

For example, could I have it ring a bell, open a popup window, send an email?

I can imagine infinite possibilities just adding system() to the end of the code, but is there another option?

For the record, I generally use R interactively in Emacs ESS, but also use R CMD Sweave and R --vanilla < from the command-line.

Community
  • 1
  • 1
Abe
  • 12,956
  • 12
  • 51
  • 72

2 Answers2

2

Try alarm()

See this post (maybe tweet that it's done?)

Community
  • 1
  • 1
Edward
  • 5,367
  • 1
  • 20
  • 17
0

if you are using linux system you may find this post helpful, where the following shell command was used.

zenity --error --text="Testing..."

you may embed it into R codes like

system("zenity --error --text='Testing...'")

it will make a prompt. However, be prepared and do not be scared.

Community
  • 1
  • 1
  • I am using linux; but what should I be prepared for / scared of? Will it launch something or run in the background? – Abe Jul 25 '12 at 14:28
  • it will just prompt a small window. if you are absorbed in editing your thesis this prompt will just shock you. other than this, nothing more. –  Jul 25 '12 at 14:29
  • be easy dirk, according to wikipedia Zenity is available for Linux, BSD and Windows and released under GPL. by non-interactive I just do not know what do you want: on one hand you want to be notified when the code finishes but by setting non-interactive you just do not want any information coming out. calm down and think it for a while. –  Jul 25 '12 at 14:57
  • 1
    a) "Available" means could possibly be installed; but its not on eg our headless (non-GUI, non-Gnome) servers -- where scripts run that may notify. b) Your answer is still inapplicable for non-interactive use. And a) and b) means your answer is still wrong (though correct for a different question such as "how do I display a pop-up box from shell"). – Dirk Eddelbuettel Jul 25 '12 at 15:24
  • Dirk I come to understand your point about the non-interactive mode which is the case when you compute something on a server. In this case I would suggest using "mail" command which is quite complicated to set. On the other hand if you just run R on localhost (as the question stated), is there any point you incline to use the non-interactive mode? Besides this, if you do not want to beep the pc speaker and you still want to play prompt on multi platform you may have to turn to java or sth. Let's come back, why do you want to bother making cross platform thing for solving such a small problem? –  Jul 25 '12 at 15:48
  • 1
    You could just as easily use package:tcltk to popup a dialog box, that would work on Linux/Mac/Windows and not need zenity. – Spacedman Jul 25 '12 at 15:54
  • Using one more package increase the risk of getting package confliction while system() calls another process and is thus safer. I got experience that R multicore package conflicts against openblas when the latter one set cpu_affinity to be true (both are famous packages right?) Besides this, a gui solution never works on a server and if a geek is so much inclined, system() plus "mail" is the final resort. --by no means is system() bad. –  Jul 25 '12 at 16:22
  • You don't system() + email if this runs from a cronjob as you get the mail part for free from cron. – Dirk Eddelbuettel Jul 25 '12 at 16:55
  • 1
    1. Poster asked about 'on localhost' not server. 2. tcltk is pretty standard, its not going to conflict with anything. 3. system+mail wont work if the server admin has stopped all possibility of his massive cluster being a spam farm. – Spacedman Jul 25 '12 at 18:07
  • 1. The discussion extended to multi-platform, server, anything, not only localhost.2 On localhost I believe minimising package usage is a good practice otherwise R will by default call then when starts. 3 If the administrator do not want the server to be a farm of anything than I cannot imagine what one can do to get oneself notified 4 If the admin leases out a channel of sending message to the user's own IP R can call rsync to bounce back a small file while the local host should listen for the file and prompt a window using tcltk or something, in this case system() is still the best choice. –  Jul 25 '12 at 22:54