Saving Graphs in R
Last updated
Last updated
Let's create a basic scatterplot by plot()
function in R.
Output:
Generally, we can save R graphs by:
By RStudio
By R code
Plots panel –> Export –> Save as Image or Save as PDF
We can also choose other formats to save in RStudio.
It is also possible to use R code to save the graphs.
Utilize functions such as jpeg(),
png(), svg()
or pdf()
to determine the files in which to save your image. You can also include additional arguments to specify the width and height of the image.
Create the plot
Close the file with dev.off()
Alternatively, we can first create the plot and then copy the plot to a graphics device.