【问题标题】:How to download several png plots within one download button in shiny如何在闪亮的一个下载按钮中下载多个png图
【发布时间】:2015-08-31 21:18:06
【问题描述】:

我对闪亮很陌生。我有几个ggplot graghs。我为每个人添加了下载按钮。
这是一个示例代码:

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 文件或 4 个单独的 png 文件。

我的问题不是关于创建一个 pdf 或 zip 文件来以常规 R 脚本导出我的所有图。我在 SHINY 应用程序中询问 downloadHandler。这是本网站上的一个独特问题。

有人可以教我怎么做吗?

【问题讨论】:

标签: r download shiny


【解决方案1】:

你可以用这种方式制作一个四页的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()
}
)

【讨论】:

  • 使用这种方法你不是把每块地收回两次而不是一次吗?
猜你喜欢
  • 2021-09-25
  • 1970-01-01
  • 1970-01-01
  • 2017-07-26
  • 1970-01-01
  • 2020-09-21
  • 2022-01-16
  • 2021-09-24
  • 2014-10-04
相关资源
最近更新 更多