How to save figures/plots from R Graphics window

Issue #864 resolved
Davinder Kaur Dhalla created an issue

Hey everyone, I am new to R. Once the graphs are generated, how do I save them into a file? I have attached the screenshot of the R Graphics window. It does not give me any option to save the plots.

Thanks in advance.

Comments (3)

  1. Xinqiu Yao

    Hi,

    You can direct the plot to a pdf, for example, by

    pdf(file=”XXX.pdf”, height=4, width=4)
    plot(XXX) # the line to make the plot
    dev.off()
    

    You can also generate a png, tiff, etc. in a similar manner. Check the doc for the corresponding command (e.g., ?pdf)

    Alternatively, you can type the following command after seeing the plotting window, to save the figure as is:

    dev.copy2pdf(file="XXX.pdf")

  2. Log in to comment