
Benjamin B. answered 06/21/19
Ecologist with 4 years of R and research experience
This can be fairly straightforward in R. First, you need to use the jpeg() function, followed by your code to create your plot, and then finally followed by the dev.off() function. Before running this code, make sure you have set your working directory so that you know where the file will be the created. You are able to name your photo whatever you desire. I used "rplot1.jpg" as an example. Your name must end with ".jpg". Note, you will need to end your code with the "dev.off()" to tell R that you are done using/creating the file. If you do not include the dev.off() code, you will not be able to open your photo and you will receive a message that states that the image is being edited in another program.
jpeg('rplot1.jpg')
plot(y~x)
dev.off()