I plot a simple linear regression using R. I would like to save that image as PNG or JPEG, is it possible to do it automatically? (via code)
There are two different
If you want to keep seeing the plot in R, another option is to use dev.copy:
dev.copy
X11 () plot (x,y) dev.copy(jpeg,filename="plot.jpg"); dev.off ();
If you reach a clutter of too many plot windows in R, use graphics.off() to close all of the plot windows.
graphics.off()