Search code examples
rpdfdendrogram

Error in plot.new() when creating PDF in R


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?


Solution

  • 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.