我是新来的闪亮。我有几个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()
}
)
Run Code Online (Sandbox Code Playgroud)
我也有year_plot,group_plot和age_plot。
目前,我想添加一个按钮,该按钮可以下载我所有的png图。它可以是包含4个png文件的zip文件,也可以是包含4页的pdf文件,也可以是四个单独的png文件。
我的问题不是关于创建pdf或zip文件以常规R脚本导出我所有图的问题。我正在询问SHINY应用程序中的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()
}
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1378 次 |
| 最近记录: |