Rstudio - plots not showing and plots menu grayed out - r

I'm using Rstudio Version 1.0.136. I'm trying to plot some data and when I execute the code nothing shows up in the 'Plot' pane and the 'Plots' drop down menu is grayed out. Any suggestions?
EDIT:
> dev.off()
null device
1
> dev.cur()
null device
1
I tried restarting R and then ran this code and got this error message:
> library(ggplot2);qplot(mpg, hp, data = mtcars)
Warning message:
R graphics engine version 12 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.

Related

WebviewPanel: FAILED posting webview/editors/didChangeVisible to the webview

I have graph output in the R/Radian console and in Jupyter, Jupyterlab, and VS Code notebooks. I also get the Rplots.pdf sent to the working directory as expected. However, I don't get embedded "pop-up" graph output when running R scripts in the VS Code editor e.g. filename.R. I always get this error message from CodeStream.
WebviewPanel: FAILED posting webview/editors/didChangeVisible to the webview; Webview is invisible and can't receive messages.
I've read a few SO questions on the Webviews, but they seem to be related to web/JSON loading issues and not R plots.
Seems I am missing a setting or package that pushes the Webview out.
Example code block if needed.
data("mtcars")
cars <- mtcars
print(nrow(cars))
print(head(cars, 10))
x <- c(0:10)
plot(x, sin(x))

Why is locator() broken in RStudio?

Does anyone know how to fix when RStudio is breaking the locator() function? If I plot
plot(1:10)
then use locator() to click on the same points (1:10), this is what I get after I click the Finish button.
locator(type = 'p', col = 'red')
$x
[1] 1.265369 2.226131 3.172336 4.147655 5.064746 6.040065
[7] 6.986270 7.947032 8.893237 9.868556
$y
[1] 1.437224 2.361029 3.265178 4.169328 5.093133 5.997282
[7] 6.901432 7.825237 8.729386 9.633536
However, if I do the same thing in the R GUI rather than RStudio, then it works just fine:
I've tried restarting my session, using dev.off(), and restarting RStudio but the problem persists. Am I missing something simple here, or maybe it's a bug in RStudio?
R version 3.3.1
RStudio 0.99.903
Mac OSX 10.11.6

How to display Markov Chain plots in Rstudio (markovchain package)

Latest Rstudio and latest R ( in Ubuntu Linux 12.04 - 32bit ).
Most plots will display OK in my Rstudio [Plots] pane.
But some Markov Chain plots throw an Error and don't display.
Here's a very simple example code:
library(markovchain) #loading the package
myMatr<-matrix(c(0,.2,.8,.1,.8,.1,.3,0,.7),byrow=TRUE,nrow = 3)
## defining a transition matrix
rownames(myMatr)<-colnames(myMatr)<-c("a","b","c")
myMc<-as(myMatr, "markovchain")
plot(myMc) # <== Error message starts after this...
gives this Rstudio Console Error:
(and no plot is displayed in Rstudio)
"Error in cut.default(x, binsToUse, labels = FALSE, include.lowest = TRUE, : 'x' must be numeric"
Yet, exactly the same R commands (as above)
work fine in "stand-alone" R 3.2.3! (outside of Rstudio).
And the Markov Chain plot is displayed ok in a new R-window...
Q:
- Is there an easy way/command to tell Rstudio
that I want certain plots
to open in a new R window (just like in pure R),
and NOT in the Rstudio Plot pane?
- Or some other easy solution?

RStudio-only error with tcl/tk?

When I compute an ROC plot with the package pROC, I get the following error in RStudio v. 99.9.9:
## Loading required package: tcltk
## Warning: couldn't connect to display ":0"
## Error: [tcl] invalid command name "toplevel".
I thought this was an issue in my OS (Debian with r-base 3.1 installed from APT depending on tcl/tk lib version 8.5), but when evaluating the same code through the terminal, I get the plot rendered without the same error.
Here is a simple example following some pROC example code that will generate the error when knitted in RStudio, but works in vanilla R:
```{r markdown.test}
library(pROC)
features <- runif(25)
labels <- as.factor(runif(25) < 0.75)
lda.model <- lda(as.matrix(features),labels)
lda.pred <- predict(lda.model,as.matrix(features))
lda.roc <- plot.roc(lda.pred$posterior[,1],
c(labels),
ci=TRUE, of="se", #specificities = seq(0,100,5),
ci.type="shape",
ci.col="#1c61b6AA")
```
The error occurs when the confidence interval parameters are added to the call.
Is there something missing from my RStudio install/config, or is this a bug?
Blast from the past! I see that same error today on an instance of RStudio installed in the IBM computing environment called CP4D. Did you ever find an answer?
I think the way to fix on your Macintosh is to install Quartz and let it serve as the X11 server to display output from programs like tcltk or maybe even hist() or quartz() devices. (my team wrote install instructions https://pj.freefaculty.org/guides/crmda_guides/47.mac_R_setup).
I'm not sure what I'll do on the CP4D thing, since it is running inside a Web browser.

ggvis, Error in normalizedPath()

I am running one of the "interactive" examples from the ggvis webpage (http://ggvis.rstudio.com/ggvis-basics.html#introduction) and I obtain an error.
I loaded the ggvis, dplyr and shiny packages.
Here is the code that I ran:
mtcars %>% ggvis(~wt) %>% layer_histograms(binwidth = input_slider(0, 2, step = 0.1))
And here is the output that I get.
Showing dynamic visualisation. Press Escape/Ctrl + C to stop.
Error in normalizePath(directoryPath, mustWork = TRUE) :
path[1]="/Builds/CRAN-QA-Simon/packages/mavericks-x86_64/Rlib/3.1/ggvis/www/ggvis": No such file or directory
I am using RStudio Version 0.98.507, and R version 3.1.0; Platform: x86_64-apple-darwin13.1.0 (64-bit).
I just found a similar thing trying to run a shiny app from RStudio.
My workaround was to devtools::install_packages("rstudio/ggvis").
I'll put a link to this from the ggvis google group.
Hope this helps

Resources