【发布时间】:2018-08-20 02:59:46
【问题描述】:
我正在尝试使用下载处理程序将我的 Shiny App 中的 ggplots 导出到单个 PDF 文件中,但它不起作用。 PDF 文件正在保存,但它只给了我最后一个 ggplot 而不是全部三个。任何帮助将不胜感激!
下面是服务器的代码:
shinyServer(function(input, output, session) {
plotinput()
{
df<-data.frame(q=c(1,3,5,7,9),w=c(2,4,6,8,10),z=c(1,2,3,4,5))
ggplot(df,aes(x=q,y=w))+geom_point()
ggplot(df,aes(x=z,y=w))+geom_point()
ggplot(df,aes(x=q,y=z))+geom_point()
}
output$allgraphs <- downloadHandler(
filename = function(){paste0("graphs.pdf")},
content = function(file){
pdf(file,onefile = TRUE)
print(plotinput())
dev.off()
}
)
})
【问题讨论】:
标签: r pdf ggplot2 download shiny