I am not able to open the plot when saved as pdf or other format. Consistently getting the following error. I am working on mac.
> plot(1:10)
> pdf('deleteIt.pdf')
> dev.off()
RStudioGD
2
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] pROC_1.5.4 plyr_1.7.1
loaded via a namespace (and not attached):
[1] tools_2.15.1
I am getting the following error. Itried with png and jpeg too, but no luck..
The file “deleteIt.pdf” could not be opened.
It may be damaged or use a file format that Preview doesn’t recognize.
You did it backwards. Try this
pdf("deleteIt.pdf")
plot(1:10)
dev.off()
Start the device. Write to it. Turn it off.
Alternatively, as pointed out by @Spacedman in a comment, you can create a pdf with whatever is currently plotted by using dev.copy
like this:
plot(1:10)
dev.copy(pdf, "deleteIt.pdf")
dev.off()
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