I am using the gWidgets toolkit to create a GUI in an R script that is run using Rscript.
When the GUI is created, the script exits.
I can prevent this with a while(TRUE){Sys.sleep(9999)} loop at the end of the script but that seems hacky.
Is there a better way of telling R to exit only when the GUI is closed, or at least to enter the REPL once the GUI is constructed?
The standard way of dealing with this is to request user input to continue. This one-liner will do the trick.
EDIT:
readlineonly works under interactive use, so I've swapped it forscan, which is a little less pretty.So you script should look like