清除 RStudio 中所有绘图的代码 [英] Code to clear all plots in RStudio

查看:123
本文介绍了清除 RStudio 中所有绘图的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有清除工作区的代码:rm(list=ls()) 和清除控制台的代码:cat("\014")

I have code to clear the workspace: rm(list=ls()) and code to clear the console: cat("\014")

是否有代码可以清除 Rstudio 中的所有绘图?

Is there code to clear all plots from Rstudio?

推荐答案

dev.off() 关闭当前图形设备.只要我目前没有打开不同的图形设备,这将为我清除 RStudio 中的所有绘图.如果您确实打开了其他图形设备,那么您可以使用 dev.list() 来确定哪个图形设备是 RStudio 的.以下应该做到这一点,但我还没有彻底测试过.

dev.off() closes the current graphical device. This clears all of the plots for me in RStudio as long as I don't have a different graphical device open at the moment. If you do have other graphical devices open then you can use dev.list() to figure out which graphical device is RStudio's. The following should do that but I haven't tested it thoroughly.

dev.off(dev.list()["RStudioGD"])

但如果您不做任何其他事情,那么只需使用 dev.off() 就可以了.

But if you aren't doing anything else then just using dev.off() should take care of it.

这篇关于清除 RStudio 中所有绘图的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆