1) Save current open screen figure as pdf file
# plot something
x=c(1,2,3,4,5)
y=c(5,2,3,4,1)
plot(x,y)
# save plot as PDF file, size 6 × 6 inch
dev.copy(pdf, 'myfigure.pdf', width = 6, height = 6 )
dev.off()
2) Print figure to pdf file (within a script)
pdf(file = 'myfigure.pdf') # create pdf file for writing
# png(file = 'myfigure.png') # or, save as PNG file
# draw boxplot (not visible on screen, draw directly into pdf-file)
x1=mydata$height
x2=mydata$width
boxplot(x1, x2, names=c("Height", "Width"), boxwex=0.4)
dev.off() # close pdf file
|
|