从R Shiny应用程序导出rmarkdown文件时,为什么文件名以“ _opt_rstudio-connect_mnt_app_”开头?

时间:2019-04-25 18:21:56

标签: r shiny r-markdown

我创建了一个闪亮的应用程序。该应用程序的一部分将允许用户使用rmarkdown创建和下载基于html的报告。这很好。

在我的本地计算机上,html文件的文件名是正常的。但是,当我部署到闪亮的服务器时,文件名始终以

表示

_opt_rstudio-connect_mnt_app _

所以看起来像

_opt_rstudio-connect_mnt_app_STUFFTHATIWANT.html

我不知道为什么。有其他人经历过吗?

我正在使用downloadHandler

我的代码是这样的:

output$report <- downloadHandler(
    # For PDF output, change this to "report.pdf"
    #filename = paste("Sample.line.report", ".html", sep = ""),
    #print(paste("This is ", report.name.title())),
    if (!is.null(report.name.title())) {
      print(c("Report Title"))
    },
    #filename = paste(report.name.title(), ".html", sep = ""),

    filename = function() {

      paste(getwd(),
            paste(
              paste(
                input[[paste0(paste(iwerquerycol[1], ".interviewer.report.name", sep =
                                  ""))]],
                Sys.Date(),
               report.name.title(),
            report.name.author(),
            sep = "_"), 
        ".html", sep = ""),
        sep = "/")
},
content = function(file) {
  # Copy the report file to a temporary directory before processing it, in
  # case we don't have write permissions to the current working dir (which
  # can happen when deployed).
  tempReport <- file.path(tempdir(), "report.Rmd")
  file.copy("report.Rmd", tempReport, overwrite = FALSE)

  # Set up parameters to pass to Rmd document
  params <- list(
    samples_data = samples.data(),
    radius.quants = radius.quants(),
    icon.interviewer = icon.interviewer,
    interviewer_data = interviewers.data(),
    airports = airports,
    nams.sample.table = nams.sample.table,
    report.title = input$report.title,
    report.author = input$report.author,
    report.interviewer.name = input[[paste(iwerquerycol[1], ".interviewer.report.name", sep =
                                             "")]],
    greenLeafIcon = greenLeafIcon,
    sample.table.column.names = sample.table.column.names
  )

  # 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).
  rmarkdown::render(
    tempReport,
    output_file = file,
    params = params,
    #map = ,
    envir = new.env(parent = globalenv())
  )
}

0 个答案:

没有答案