dev.copy() results in Error in device(...) : unable to start png() device

Who can help?
curve(exp(x), from=0, to=1)
dev.copy(png, file = "test.png")

Error in device(...) : unable to start png() device
In addition: Warning messages:
1: In device(...) : unable to open file 'test.png' for writing
2: In device(...) : opening device failed

Should be a piece of cake but I cannot find the error ...
RStudio Version 1.1.453 Windows 10
Works without problem in the WIndows RGUI and Linux, but not in RStudio.
Any help appreciated.

It works for me. Have you set the working directory properly, for example by creating a project?

Or, try dev.off() a few times to close any old device connections.

Or you might have "test.png" open in another software, and need to close it.

1 Like

You can also try to restart your R session before running your code
Ctrl+Shift+F10

curve(exp(x), from=0, to=1)

dev.copy(png, file = "test.png")
#> png 
#>   3

Created on 2019-02-28 by the reprex package (v0.2.1)

1 Like

Hi woodward,
thanks for your effort, even if I still didn't get it working. I decided to use the R-GUI for saving plots. Not the best solution, but saves me a lot of time ...

Hi andresrcs,
unfortunately, this didn't help either. Anyway, thanks for giving me a hint!
Best
Thule

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.