When plotting a dendrogram in R, I get a funny error that I've never seen before.
Error in plot.new() :
cannot open file 'C:\Users\Sun\AppData\Local\Temp\RtmpKSRNuD\pdf12207aa37548', reason No such file or directory
I didn't have that error yesterday when plotting other dendrograms and saving it in PDF files .. Any idea what it means?
new() : figure margins too large. One error you may encounter in R is: Error in plot.new() : figure margins too large. This error occurs when the plot panel in RStudio is too small for the margins of the plot that you're attempting to create.
This error occurs when you attempt to perform some action that requires a plot to already exist in R, yet a plot does not exist. The following examples show how to fix this error in practice.
You can adjust the size of the margins by specifying a margin parameter using the syntax par(mar = c(bottom, left, top, right)) , where the arguments bottom , left … are the size of the margins. The default value for mar is c(5.1, 4.1, 4.1, 2.1).
The above error means plot is not being created yet hence abline function cannot be used to draw anything on the plot. Therefore, a plot needs to be created first to use abline function for creating a line or any other thing.
Related answer at Plot() error when using REngine.Rserve suggests sending a dev.close()
call as a workaround for "not closing the device correctly last time" (specifically under Rserve).
Related answer at Cannot open file '', reason No such file or directory suggests using file.path
as a alternative to paste
for creating filenames with platform-independent path separators.
I'm having better luck with graphics.off()
. The difference is that dev.close()
closes the current device, graphics.off()
closes all open devices. In my case, I'm writing a PDF inside a knitr Rmd called from an Rserve session, so I may have multiple open devices.
I'm also finding that there's a mysterious folder named (null).1001.1001
(it's on an Ubuntu box, logged in as uid 1001, gid 1001). The presence of this folder seems to help in my case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With