To save a plot with R commands and not point-and-click, first create a container for your image using a function such as jpeg(), png(), svg() or pdf(). Those functions need to have a file name as one argument and optionally width and height, such as:
jpeg("myplot.jpg", width=350, height=420)
Generate the plot with whatever graphics functions it requires, such as:
And then issue the command:
That will save your graphic to its container.
If you are using ggplot2, you can also use the function ggsave(), which defaults to saving the last plot you created using ggplot2 at the size you displayed it. Based on the filename you pass to the ggsave() function, it will save in the appropriate format — myplot.jpg saves as a JPEG, myplot.png saves as a PNG and so on.
One final note: If you're working in RStudio and would like to see a larger version of your plot, click the Zoom button and a larger window with the current graphic will open. And, also in RStudio, to see previous plots from your session, click the back arrow.
Sign up for CIO Asia eNewsletters.