How to solve TIFFOpen Error Popup in RStudio? - r

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

Related

Unable to launch ggplot graphs on Kaggle, always get 'Error in parse(text = x, srcfile = src): attempt to use zero-length variable name Traceback':

I had my Rmrkdown file running well on Rstudio and got knit to html fine.
And it could also be saved successfully on Kaggle with all R and Notebook options ensured.
It just can show the graphs on Kaggle. Can help?
My file is here to share https://www.kaggle.com/helenchoi/bellabeat-marketing-for-spring-assignment?scriptVersionId=75128488 , please advise. Thanks.
Helen

Error in file(con, "w") : cannot open the connection [Using R-Studio to plot interactive bar graphs using rCharts, knitr]

I am getting an error when I am trying to run the code below in R-Studio 3.3.2 on a Mac (OS Sierra)
devtools::install_github('ramnathv/rCharts')
install.packages("knitr")
require(rCharts)
require(knitr)
haireye <- as.data.frame(HairEyeColor)
n1 <- nPlot(Freq ~ Hair, group = 'Eye', type = 'multiBarChart',
data = subset(haireye, Sex == 'Male')
)
n1$save('fig/n1.html', cdn = TRUE)
cat('<iframe src="fig/n1.html" width= 100%, height=600</iframe>')
Pls see output below:
Error in file(con, "w") : cannot open the connection
In addition: Warning message: In file(con, "w") : cannot open file 'fig/n1.html': No such file or directory
But I am able to generate the reqd bar graph in the viewer when I use:
n1$show(cdn = TRUE)
in lieu of n1$save('fig/n1.html', cdn = TRUE)
To take care of write permission issues (if any), I also tried including the line below, altering the WD path wherever necessary.
knitr::knit2html('Users/documents/n1.html')
But it did not help. I see the n1.html file created but it only opens an empty browser.
Any help to resolve this is appreciated.
Best,
S
A lot of times we face this error due to caching in RStudio and in that case, actual code errors don't show up. Restart RStudio and this error will be gone and actual code errors would show.
You have two separate problems.
The connection error appears because the fig/ folder does not exist. Create the folder and the save command will work. R has functions to check the existance of directories and create new ones if you would like to do it in your code.
The second problem comes from the way you save, you should use n1$save('fig/n1.html', standalone = TRUE). Here you have a similar situation.
As a side-note, I would say rCharts is not currently developed or mantained at all, so I would recommend you to use another library for your charts. In my opinion Plotly is quite nice. rCharts brought the NVD3 project to R and the chart style is in my opinion really nice. However, as far as I know both projects are stopped so I would look for a library that is still alive.
I have fixed this problem with good old rm(list=ls()) . I know I have
fallen into sequences where the error stops execution of my script. I fix the error, and then it won't run. This is likely due to lazy evaluation but it is a near impossible problem to diagnose, so the solution at the top works almost all the time.

R not producing a figure in jupyter (IPython notebook)

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)

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

Error in ls(envir = envir, all.names = private)?

The below error keeps coming up inconsistently when I try to read excel files into R using the 'XLConnect' package.
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
I have actually run into this error while even using other packages that read excel files like package 'xlsx' and 'xlsReadWrite'. Many times restarting the R session solves this problem, which leads me to think that something else I am doing in my R session is changing the environment and not allowing me to load excel files anymore. Below is the latest example of code that is causing this error. In this case I know that the following coding sequence is causing the error to appear - but why is that happening? And how can I get past this error if I need the chron package.
library("XLConnect")
wb2 <- loadWorkbook("excel_file", create = FALSE)
library(chron)
wb2 <- loadWorkbook("excel_file", create = FALSE)
Anyone else run into this issue before? Any help on this issue is greatly appreciated!
Before reopening the workbook try removing the reference to previously opened one, so:
rm(wb2)
wb2 <- loadWorkbook("excel_file", create = FALSE)
Also, make sure that "excel_file" is not open by excel or any other program while you run the R test.
I've seen the same error come up when using XLConnect and the above seemed to help.
Had this problem a couple of times and the call stack looks like this message is generated when a "OutOfMemory" Exception is thrown.
To solve this problem I used:
options( java.parameters = "-Xmx4g" )
to increase the heap size rJava is able to use.
Debugging with options(error=utils::recover) helped a lot, because the R error messages are not very specific.

Resources