【发布时间】:2019-08-22 13:50:43
【问题描述】:
我想从闪亮服务器上的闪亮应用生成 pdf 报告。它在我的电脑上运行良好。 我尝试放入闪亮的服务器,但是当我想生成报告时,我得到一个 firefox“找不到文件”页面而不是获取 pdf。
我使用的代码显示在:https://shiny.rstudio.com/articles/generating-reports.html 我也尝试直接使用我的 .Rmd 文件,而不是将其复制/粘贴到临时目录,但我得到了同样的错误。
我的服务器文件:
output$pdfGen <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = "rapport_preci.pdf",
content = function(file) {
withProgress(message = "Génération du pdf en cours", value = 0,{
src <- normalizePath('report.Rmd')
# temporarily switch to the temp dir, in case you do not have write
# permission to the current working directory
owd <- setwd(tempdir())
on.exit(setwd(owd))
file.copy(src, 'report.Rmd', overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- list(varSite = input$pdfSite,
...
varTrans= input$valTrans1
)
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
out <- render("report.Rmd", output_file = file,
params = params,
encoding = "UTF-8"
)
file.rename(out, file)
})
}
)
我认为我的应用没有找到我的 .Rmd 文件,但我该如何解决呢?我所有的文件都在同一个文件夹中。
【问题讨论】:
标签: r shiny r-markdown