Can anyone tell how can I interrupt a running script in R?
Let's say I have an infinite loop or some other problem, and I want to stop the script from running. Is there a keyboard command that does that?
If it helps any, in Python it is Ctrl + c. I tried that in R, and it didn't work :).
I did some search for this seemingly simple question, but could not find the answer.
Thanks in advance.
In R Studio, Rgui, and R. APP, pressing the Esc key interrupts the running code. R Studio also offers a Stop button and a menu option to stop running code with the mouse. In the R command-line interface, the Ctrl + C command stops the execution of the code.
6.1 Running code The key to using the script editor effectively is to memorise one of the most important keyboard shortcuts: Cmd/Ctrl + Enter. This executes the current R expression in the console.
Self Answer (pretty much summary of other's comments and answers):
In RStudio
, Esc
works, on windows, Mac, and ubuntu (and I would guess on other linux distributions as well).
If the process is ran in say ubuntu shell (and this is not R
specific), for example using:
Rscript my_file.R
Ctrl + c
kills the process
Ctrl + z
suspends the process
Within R shell, Ctrl + C
kills helps you escape it
Control-C works, although depending on what the process is doing it might not take right away.
If you're on a unix based system, one thing I do is control-z to go back to the command line prompt and then issue a 'kill' to the process ID.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With