💾Saving Graphs in R
Create a Plot
Let's create a basic scatterplot by plot()
function in R.
Output:
Saving Graphs
Generally, we can save R graphs by:
By RStudio
By R code
By RStudio
Plots panel –> Export –> Save as Image or Save as PDF
We can also choose other formats to save in RStudio.
By R code
It is also possible to use R code to save the graphs.
Utilize functions such as
jpeg(),
png(),svg()
orpdf()
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.
Last updated