I would like to create a function to save plots (from ggplot
).
Here is a data frame:
### creating data frame
music <- c(\"Blues\", \"Hip-
If you would like an image file instead of a pdf, also the following works
ggsave(filename="myPlot.jpg", plot=last_plot())
or with additional parameters, as follows.
ggsave(filename="myPlot.jpg", plot=lastplot(),
width = 10, height = 5,
units = "cm", # other options are "in", "cm", "mm"
dpi = 200
)
Also following file types are supported "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf".