After R is done running a long data crunching process, you may need to notify the operator to check the R console and provide the next commands. Without installing any more software or creating any batch files or VBS scripts, here is a simple way to create the popup notice in Windows:
system('CMD /C "ECHO The R process has finished running && PAUSE"', invisible=FALSE, wait=FALSE)
R will launch a command prompt window with the message (which can be customized, of course), and the notice stays open until manually closed.
This trick was adapted for R from Dave Webb on stackoverflow.com.
Tested with R 2.15.2 and R 3.0.0 on Windows 7.
Does not work when nested in a function, it instead shows it only on the console, and somehow the wait = true does not work.
It won’t stop the process and just keep going.
Any reason for it?
I just found out setting wait = true makes it run in the console instead of showing the popup, my bad.
Is there a way to stop everything until return is pressed?
Nice Trick!
Unfortunately, I was not able to customize it fully. This code
subject <- "My message"
message <- paste('CMD /C "ECHO',subject,'"' )
system(message, invisible=FALSE, wait=FALSE)
blips a window, which does not stay. Is there a way around it?
My mistake. Here is a correction that works:
subject <- "My message"
message <- paste('CMD /C "ECHO',subject,'&& PAUSE"' )
system(message, invisible=FALSE, wait=FALSE)
Pingback: [SOLVED] Scheduling an an R script that shows a popup/message box in case of an error on Windows – BugsFixing