I would like to run an R script using a single command (e.g. bat file or shortcut).

This R script asks the user to choose a file and then plots information about that file. All is done via dialog boxes.

I don't want the user to go inside R - because they don't know it at all.

So, I was using r cmd and other similar stuffs, but as soon as the plots are displayed, R exits and closes the plots.

What can I do?

Thanks for your help.


1 Answer 1


This looks like a similar kind of a problem.

Solutions: (taken from above source)

  1. Just sleep via Sys.sleep(10) which would wait ten seconds.

  2. Wait for user input via readLines(stdin()) or something like that [untested]

  3. Use the tcltk package which comes with R and is available on all platforms to pop up a window the user has to click to make the click disappear. That solution has been posted a few times over the years on r-help.

2nd option is better to use for the user.

P.S. Since I did not come up with the answer myself, I tried to put it in comment but my reputation is too low for that.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.