r Shiny-下载uioutput作为pdf
我正在尝试创建一个在我的Shiny应用中与下载者一起使用的R Markdown文件。在R标记中,我只需要一个简单的UIOutput。以下是我尝试将其传递到降价文件中的方式。
在服务器中:
output$myOutput <- renderUI({
... # the output that needs to be printed
})
output$downloadChart <- downloadHandler(
filename = "report.pdf",
content = function(file) {
tempReport <- file.path(tempdir(), "report.Rmd")
file.copy("report.Rmd", tempReport, overwrite = TRUE)
params <- list(report = output$myOutput)
rmarkdown::render(tempReport, output_file = file, params = params, envir = new.env(parent = globalenv()))
}
)
report.rmd
---
title: "report"
output: pdf_document
params:
report: NA
---
```{r}
params$report```
使用上述代码时,下载了HTML文件。我真的不明白为什么这是因为我已经指定了PDF。这不是制作可下载文件的正确方法吗?我很新鲜。任何帮助将不胜感激!
I am trying to create a R markdown file that works with the downloadHandler in my shiny app. In the r markdown I just need a simple uiOutput. Below is how I attempted to pass it into the markdown file.
In server:
output$myOutput <- renderUI({
... # the output that needs to be printed
})
output$downloadChart <- downloadHandler(
filename = "report.pdf",
content = function(file) {
tempReport <- file.path(tempdir(), "report.Rmd")
file.copy("report.Rmd", tempReport, overwrite = TRUE)
params <- list(report = output$myOutput)
rmarkdown::render(tempReport, output_file = file, params = params, envir = new.env(parent = globalenv()))
}
)
report.Rmd
---
title: "report"
output: pdf_document
params:
report: NA
---
```{r}
params$report```
When the code above is used, a HTML file is downloaded. I don't really understand why is this so since I already specified PDF. Is this not the right way to produce a downloadable file? I'm very new to R shiny. Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论