r语言 - 如何在一个闪亮的下载按钮内下载几个png图



我对闪亮很陌生。我有几个图形。我为每一个添加了下载按钮。
下面是一个示例代码:

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()
}
)

我也有year_plot, group_plot和age_plot。

目前,我想添加一个按钮,可以下载我所有的png情节。它可以是包含4个png文件的zip文件或包含4个页面的pdf文件或四个单独的png文件。

我的问题在这里不是关于创建一个pdf或zip文件导出我的所有情节在常规R脚本。我问的downloadHandler在闪亮的应用程序。这是本网站上唯一的问题。

有人能教我怎么做吗?

你可以用这种方法制作一个四页的pdf文件。

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()
}
)

最新更新