How to plot in RStudio and not have a new window p

2019-06-15 07:12发布

问题:

Whenever I plot any plot in RStudio, I get a new device window that pops up. This was not always the case. I must have changed some settings. How do I change the settings back to have plots go to the RStudio plot window?

I have explored the dev.off() and other dev functions without success. For example:

# Clear workspace
rm(list=ls())

# create data
set.seed(1)
x <- rnorm(100, 0, 1)
y <- rnorm(100, 3, 1)

plot(x,y)

produces the popped up window in the screenshotted image:

I want the device to stay in the RStudio plot window in the lower righthand corner. Does anyone have any help? I saw a similar question here that claims that an update will fix the issue. I updated within the last week. When I use sessionInfo() I am running R version 3.3.2, what I believe to be the latest version of R.

回答1:

For others who like me may still encounter this issue:

This is probably caused by an R update to 3.3.2 and is fixed by installing a newer version of RStudio. In my case 1.0.136 did the trick.



回答2:

I know that this has been answered but the problem can arise in multiple ways. My issue had been much simpler. The plots were not showing up in the Rstudio plot pane simply because the default null GD was turned off via dev.off(). I'm running Rstudio Version 1.1.442 with R Version R-3.4.4

I ran dev.off() a few times until all windows including hidden ones were closed and I received the following response in the console window.

null device 1

I then ran this and the plot appeared in the RStudio plot pane

dev.new()
plot(mtcars$mpg~mtcars$disp)


回答3:

Go to R studio menu bar and Tools->Global options->R Mark down In that phase select "window" from that list in the "show output preview in:" then apply



回答4:

I solved this problem by updating RStudio (Help--> check for updates). The new version of RStudio I updated to is Version 1.1.383 and this problem was fixed. Currently I have version 3.4.3 for R.



标签: r plot rstudio