How do I prevent Rplots.pdf from being generated?

孤街浪徒 提交于 2019-11-30 17:14:42

I wonder if you have another command that opens a device before or after the code snippet you've given us. When you're all done run dev.cur() to see if there was a device left open. If not, it should return the null device.

Here are ways you can recreate getting a Rplots.pdf or a Rplot001.png; the layout and par commands open a device if one isn't open, and since no filename has been given, it uses the default filename.

options(device="pdf")
layout(1:4)
dev.off()

options(device="png")
par()
dev.off()

Maybe seeing that happen here will give you a clue as to what's happening with your code.

I know this is a very old post and surely the OP has solved this. But I encountered this similar situation while working with plotly. Converting a ggplot output into a plotly output generated the similar error of not being able to open file 'Rplots.pdf'.

I solved it by simply including :

pdf(NULL)

I'm not sure of the reason for the error, have not been able to figure that out, but this small line helped removing the error and displaying my plots as I would expect in plotly and ggplot combinations.

Andrie

Here is the source code for CairoPNG:

function (filename = "Rplot%03d.png", width = 480, height = 480, 
    pointsize = 12, bg = "white", res = NA, ...) 
{
    Cairo(width, height, type = "png", file = filename, pointsize = pointsize, 
        bg = bg, ...)
}

This tells you that CairoPNG takes filename=... as a parameter, and passes this to Cairo as the file parameter.

I can see how this can lead to confusion, but the point is that your call to CairoPNG should be:

CairoPNG(filename="graphs.png")

See if that works...

I had a similar problem recently after upgrading to R-3.0.3 (yes we're a little behind!). It turns out that palette("default") opens a device now, though it didn't used to.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!