【发布时间】:2014-12-03 16:39:46
【问题描述】:
有没有一种方法可以将(UI 端)Shiny plots 输出为 PDF 供应用程序用户下载?我尝试了各种类似于涉及ggplot的方法,但似乎downloadHandler不能这样操作。例如,以下内容只会生成无法打开的损坏 PDF。
library(shiny)
runApp(list(
ui = fluidPage(downloadButton('foo')),
server = function(input, output) {
plotInput = reactive({
plot(1:10)
})
output$foo = downloadHandler(
filename = 'test.pdf',
content = function(file) {
plotInput()
dev.copy2pdf(file = file, width=12, height=8, out.type="pdf")
})
}
))
非常感谢您的帮助。
【问题讨论】:
-
作为参考,@Victorp 的以下方法在 shinyapps.io 和
Error: can only print from a screen device托管时失败。