Popup notification from R on Windows

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.

Advertisement

5 thoughts on “Popup notification from R on Windows

  1. 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?

  2. 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)

  3. Pingback: [SOLVED] Scheduling an an R script that shows a popup/message box in case of an error on Windows – BugsFixing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s