I am very new to shiny. I have several ggplot graghs. I added download button for each of them.
Here is an sample code:
output$salary_graph <- renderPlot({
print(salary_plot())
})
output$salary_plot_dl <- downloadHandler(
filename = function() {
"salary_plot.png"
},
content = function(file) {
png(file)
print(salary_plot())
dev.off()
}
)
I also have year_plot, group_plot and age_plot.
Currently, I would like to add a button which can downloads all my png plots. It can be a zip file which contains 4 png files or pdf file with 4 pages or four separate png files.
My questions here is not about creating a pdf or zip file to export all my plots in regular R script. I am asking the downloadHandler in the SHINY application. It is a unique question on this website.
Can someone teach me how to do it?
You could make a pdf file with four pages in this way.
output$salary_graph <- renderPlot({
print(salary_plot())
})
output$salary_plot_dl <- downloadHandler(
filename = function() {
"Rplots.pdf"
},
content = function(file) {
pdf(file)
print( salary_plot() )
print( year_plot() )
print( group_plot() )
print( age_plot() )
dev.off()
}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With