How to save a plot as image on the disk?

后端 未结 11 1223
失恋的感觉
失恋的感觉 2020-11-22 10:38

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

11条回答
  •  萌比男神i
    2020-11-22 10:42

    To add to these answers, if you have an R script containing calls that generate plots to screen (the native device), then these can all be saved to a pdf file (the default device for a non-interactive shell) "Rplots.pdf" (the default name) by redirecting the script into R from the terminal (assuming you are running linux or OS X), e.g.:

    R < myscript.R --no-save
    

    This could be converted to jpg/png as necessary

提交回复
热议问题