1

The command rm(list=ls()) is used clear the R workspace (i.e. clear all the objects shown by ls()). To clear the console, I personally do like pressing CTRL + L but you can alternatively use cat("\014"). To clear all the plots, you can use dev.off(). However, this doesn't clear a 3D plot in RGL devices opened in XQuartz on Mac. My questions are:

  1. Is there a single command to clear the workspace and all the plots at the same time?
  2. Any command to remove all the plots irrespective of the graphical device that we use

Any pointers to get around this are appreciated.

Desta Haileselassie Hagos
  • 23,140
  • 7
  • 48
  • 53
  • 1
    `?dev.off` -> `graphics.off()`. –  Jan 28 '16 at 07:29
  • @Gregor, yeah sure I know but i wanted to avoid using the GUI and that's why. – Desta Haileselassie Hagos Jan 28 '16 at 07:43
  • If that's the case, then [duplicate here](http://stackoverflow.com/q/6313079/903061). I think the only difference is you haven't mentioned unloading packages. Restarting R will obviously not have any packages loaded beyond the defaults, whereas your question seems to want everything cleared up *except* packages. – Gregor Thomas Jan 28 '16 at 07:43
  • With no clarification about differences from the suggested dupe, I'm voting to close. Happy to re-open if the answers there aren't satisfactory. – Gregor Thomas Jan 28 '16 at 17:21
  • @Gregor, I already have seen that buddy and voting to close a question is not fair. – Desta Haileselassie Hagos Jan 28 '16 at 19:17
  • As I said, I'm happy to re-open if you edit your question explain why the answers there don't work for you. – Gregor Thomas Jan 28 '16 at 19:40
  • G. Grothendieck's answer looks very applicable, as do Adam Perelman's two answers. – Gregor Thomas Jan 28 '16 at 19:41
  • @Gregor, I tried it but that doesn't work for ALL graphical devices (for example RGL devices as I stated in my question). I – Desta Haileselassie Hagos Jan 28 '16 at 21:21
  • Strange, `.rs.restartR()` closes RGL devices for me as in [this answer](http://stackoverflow.com/a/33102389/903061): e.g. `rgl::plot3d(1, 1, 1); .rs.restartR()`. My RGL windows is closed. [This answer](http://stackoverflow.com/a/33738713/903061) combines `.rs.restartR()` with `cat("\014")` to also clear the console. Does this not work for you? – Gregor Thomas Jan 28 '16 at 21:37
  • @Gregor, it is strange indeed buddy. It is OK and yeah will manually clear them all. – Desta Haileselassie Hagos Jan 28 '16 at 23:14

0 Answers0