Saving Plots in R & RStudio

I recently got a question from a user about saving plots in R – To do so try the following commands:

jpeg(‘rplot.jpg’)
plot(x,y)
dev.off()