Graphics devices: Opening and saving diagrams

Install required packages

Cairo

Device margins

Device margins
Device margins

See also the RStudio cheat sheet: How big is your graph?

Opening and closing a device

png pdf pdf pdf 
  2   3   4   5 
pdf 
  5 
pdf 
  3 
pdf 
  4 
pdf 
  5 

Saving plots to a graphics file

Regular R device

pdf(), png() and jpeg() are functions that open a graphics file of the corresponding type. See ?device for more.

Device from package Cairo

Cairo() has a dpi option for choosing the graphics resolution in the output file. Option type chooses the type of the graphics file.

plot of chunk diagDevice01
plot of chunk diagDevice01
png 
  2 

Detach (automatically) loaded packages (if possible)

Get the article source from GitHub

R markdown - markdown - R code - all posts