I am very excited about using python and R together and tried using R in Jupyter (ipython notebbok), however, I could not generate figures in the R kernel.
The error message shown below is displayed when I try to plot figures. I highly appreciate your help.
I am using Anaconda and windows 8.
x<-1:10
plot(x)
Error in png(tf, width, height, "in", pointsize, bg, res, type = "cairo", : unable to load winCairo.dll: was it built?
Error in jpeg(tf, width, height, "in", pointsize, quality, bg, res, type = "cairo", : unable to load winCairo.dll: was it built?
The following is displayed in the Anaconda command prompt:
Unable to load 'C:/Users/aa/Anaconda/R/library/grDevices/libs/x64/winCairo.dll'
I found a solution from the post on this group.
Solution I did:
I had the most release of R (R 3.2.0) and following the discussion in the above link, I installed R 3.1.3 and copied winCairo.dll from C:\Program Files\R\R-3.1.3\library\grDevices\libs\x64 to C:\Anaconda\R\library\grDevices\libs\x64.
Copying winCairo.dll from R 3.2.0 does not work for my case.
With this, it plots a figure but with an error message that says "Error in replayPlot(obj): invalid graphics state"
Then, thanks to this link,
I added 'options(jupyter.plot_mimetypes = 'image/png')' and it works fine.
options(jupyter.plot_mimetypes = 'image/png')
x=1:10
plot(x)
Related
I am running spThin from the package "spThin" in RStudio
I am trying to save the plot generated from plotThin function
Following is my code after the spThin function:
tiff(file = paste(n, "plotThin2.tiff", sep = "_"))
plotThin(ca.thin, which = 2)
dev.off()
However, I get /n_plotThin2.tiff: Cannot Open.
I don't think it is the issue with my code as I went the code another 2 computers without problem but only this computer
If I switched from tiff to jpeg()
I get Error during wrapup: unable to start jpeg() device
I am running R 3.6.2
Can someone help please. Thank you
I want to create a lognormal (or other distribution) probability plot in R (for R-studio). I have looked around on the web for an example but none of the examples tell me what package I need to install in order to use the function.
logn_prob_plot <- function()
{
x<-rlnorm(10,5,1)
x
probplot(x,qdist=qlnorm,xlab="failure time",ylab="lognormal probability")
}
Error in probplot(x, qdist = qlnorm, xlab = "failure time", ylab = "lognormal probability") : could not find function "probplot"
Writing up the comment thread as an answer:
The error (could not find function "probplot") is showing up because a necessary package is not installed. It's not specifically related to creating a probability plot.
Googling "r probplot" turns up the documentation for the package e1071, which is available in CRAN.
The package can be installed by entering install.packages("e1071") in your terminal or by selecting Tools -> Install Packages in the RStudio GUI. You can then load that package using library("e1071").
I've installed the newest version of the rgl package by means of advice from the link below:
How do I install the latest version of rgl?
Then i tried to reproduce the code example of the answer from the post:
Adding a legend to an rgl 3d plot
Everything is working Ok except the command:
legend3d("topright", legend = paste('Type', c('A', 'B', 'C')), pch = 16, col = rainbow(3), cex=1, inset=c(0.02))
After executing the above command i have the warning message and no legend on the 3dplot in fact:
Warning messages:
1: In rgl.material(color = color, back = back, ...) :
RGL: Pixmap load: file format unsupported
2: In rgl.material(color = color, back = back, ...) :
RGL: Pixmap load: failed
How i can fix it? Thank you in advance.
From the comments, it appears you don't have zlib in a place where R (or the rgl configure script) can see it. The location for it is currently given in the LOCAL_SOFT variable in R_HOME/etc/<ARCH>/Makeconf.
What you put there depends on which R version you're using. For 3.2.x or 3.3.x, I believe you can get suitable contents from https://cloud.r-project.org/bin/windows/extsoft/.
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?
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.