Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to kill plotting process in R?

Tags:

r

Sometimes I have very heavy plots in a device in my R session. When, for instance, I change the size of the window where the device is pointing to it gets redrawn quite slowly. Typing Ctrl+C does not seem to kill the plotting task.

Is there a way of "cancelling" or killing a plot in R while it is being drawn?

Edit: I am using Linux and just the normal R shell from a terminal (gnome-terminal usually). Regardless of what system I use I guess there can be many answers covering each system or an integrative answer which shows how to perform this operation on any system.

like image 697
pedrosaurio Avatar asked Aug 13 '12 19:08

pedrosaurio


Video Answer


1 Answers

there is a kill function in package fork http://cran.r-project.org/web/packages/fork/index.html

Now since R doesn't spawn a seperate gnuplot process or smth that you can kill i think you will be able to send a SIGINT to the actual R process to stop the computation. so INT is usually 2 on unices and you want to send a kill -2 to the PID of the R process.

the bad way to do that would be through a

system('pkill -2 R')

:) cheers

like image 135
ramrunner Avatar answered Sep 19 '22 12:09

ramrunner