Saving and exporting graphs
In this recipe, you will learn how to save and export our graphs to various useful formats.
How to do it...
To save a graph as an image file format such as PNG, we can use the
png("scatterplot.png") plot(rnorm(1000)) dev.off()
The preceding command will save the graph as
scatterplot.png in the current working directory. Similarly, if we wish to save the graph as JPEG, BMP, or TIFF, we can use the
tiff() commands, respectively.
If you are working in Windows, you can also save a graph using the graphical user interface. First, make your graph, make sure that the graph window is the active window by clicking anywhere inside it, and then navigate to File | Save as | Png or the format of your ...