How can I interrupt the current code in R using the keyboard command?

Can anyone tell how can I abort a script run in R?

Let's say I have an infinite loop or some other problem, and I want to stop the script from starting. Is there a keyboard command that does this?

If this helps anyone, in Python it's Ctrl + c. I tried this in R and it didn't work :).

I was looking for this seemingly simple question, but could not find the answer.

Thanks in advance.

+56
r
Dec 03 '11 at 19:57
source share
3 answers

Self Answer (to a large extent a summary of other comments and answers):

  • In RStudio , Esc works in windows, Mac, and ubuntu (and I would also suggest other Linux distributions).

  • If the process is running, say the ubuntu shell (and this does not apply to R ), for example, using:

     Rscript my_file.R 

    Ctrl + c kills the process

    Ctrl + z pauses the process

  • Inside the R shell, Ctrl + c kills help you avoid this.

+39
Mar 28 '15 at 0:17
source share

Control-C works, although depending on what this process does, it may not be immediately accepted.

If you are using a unix-based system, one thing I do is control-z to return to the command prompt and then issue β€œkill” for the process id.

+11
Dec 03 '11 at 19:59
source share

Try Ctrl + z But it will kill the process, not pause it.

+6
Dec 03 2018-11-12T00:
source share



All Articles