# NOT RUN {
ggplot(mtcars, aes(mpg, wt)) + geom_point()
ggsave("mtcars.pdf")
ggsave("mtcars.png")
ggsave("mtcars.pdf", width = 4, height = 4)
ggsave("mtcars.pdf", width = 20, height = 20, units = "cm")
# delete files with base::unlink()
unlink("mtcars.pdf")
unlink("mtcars.png")
# specify device when saving to a file with unknown extension
# (for example a server supplied temporary file)
file <- tempfile()
ggsave(file, device = "pdf")
unlink(file)
# }
Run the code above in your browser using DataLab