# NOT RUN {
# Set device to jpeg (remember to update file extensions for printed plots)
options(plot.device=jpeg)
qdraw(plot(1:10), "plot.jpeg")
# Enable automatic plot format inference
options(plot.device=NULL)
# Plot directly to file (format is inferred from filename extension)
qdraw(plot(1:10), "plot.pdf")
# Plot to screen, then print to file (display will not be closed)
qdraw(plot(1:10), "plot.png", device=NA)
# If an error occurs, be sure to clear the current plot
dev.off()
# or clear all plots
graphics.off()
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab