sds
sds

Reputation: 60014

How do I interrupt R?

Sometimes R takes a lot of time to finish a trivial task, like when I ask it to print something and it turns out that it is too long or complicated and R just sits there at 100% CPU utilization. What are my options? Ctrl-C does not help. Is there a way to kill R so that it saves the workspace beforehand?

PS. I am running under Emacs/ESS on Mac OS X. I know about process management under Unix (C-c, C-z, bg/bg, kill &c). I wonder about R-specific tricks (e.g., "if you send signal SIGUSR1 to R, it will silently save workspace and exit immediately" - believe it or not, I wrote the previous sentence before I found the linked answer :-).

Upvotes: 5

Views: 22253

Answers (2)

Danny
Danny

Reputation: 3336

If Ctrl-c (or the stop sign button in Rstudio or RGui) is not working then your options are limited. If you must save your work you will just have to wait. If you're in Linux you can move it to the background by pressing Ctrl-z followed by the bg command. When you want to check on it run fg to bring it back up. In Windows press the minimize button :)

You can still kill the process to stop it, but you will lose any unsaved work.

To kill the process in Linux:

  • Hit Ctrl-z to move R to the background
  • Run ps and find the process id
  • Run kill [id] to kill the process (if it is still not stopping use kill -KILL [id])

To kill the process in Windows:

  • Hit Ctr-Shift-Esc to bring up task manager
  • Go the the processes tab
  • Select the R session process (rsession.exe for RStudio)
  • Click "End Process"

Upvotes: 3

Danny M.
Danny M.

Reputation: 281

When you run code in RStudio, there should be a little 'Stop sign' in the console. Try clicking that. Most times you won't see this stop sign unless the code that you are running takes a while.

Upvotes: 0

Related Questions