In R, if I have already create a plot on the screen, is there a way to write it to a file, without rerun the plotting code again?
Is the quality same as plotting to a file directly? (e.g. when saved to pdf, can get copiable text and scalable showing of the plot)
Thanks!
Yes, use dev2bitmap
plot(1:10)
dev2bitmap("test.png")
EDIT: Note that you need GhostScript installed. The above code ran fine on my machine (OSX 10.9.2) with 0 tinkering, and I'm pretty sure I never installed GS myself ... but it may have been installed with a larger package, etc, so YMMV.
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