hadley/ggplot2 — pull request #939 by sebkopf (2014-04-07 00:32:18+00:00)
Title: file extension parameter for ggsave() to allow device specification for files without extension

Thank you for the fantastic ggplots package!

This is a suggested implementation for specifying a file extension in ```ggsave``` to allow device matching (pdf, png, jpg, etc.) for filenames without extension. The suggestion is motivated by the problem of using ggsave in a shinyApp for letting the user download a plot (for example addressed on StackOverflow here: http://stackoverflow.com/questions/14810409/save-plots-made-in-a-shiny-app). Because the shiny server provides a temporary file without extension, ggsave can't match to any of the internally defined device functions. I'm not aware of a currently available solution to this problem and although there are several work-arounds, I like the simplicity of ggsave and wanted to suggest this solution (not sure if it's the best way to do it, but it's the most elegant I could think of). This would allow use of ```ggsave``` for a shinyApp ```downloadHandler``` like so:

```coffee
# In ui.R:
downloadLink('downloadPlot', 'Download')

# In server.R:
output$downloadPlot <- downloadHandler(
filename = "myplot.pdf",
content = function(file) {
ggsave(file, plot = qplot(speed, dist, data = cars), ext = "pdf")
}
)
```
I'm relatively new to GitHub and this is my second contribution to someone else's project, please forgive if I'm missing some specific conventions or etiquette about forking/pull requests.

Sebastian