是否有用于HTML输出以呈现到Word文档的特定程序包?

时间:2019-05-30 19:43:30

标签: r shiny r-markdown

我有一个从Shiny Application呈现的交互式文档。该报告包含DT数据包中带有格式的表格。当我在本地运行该应用程序时,它会提供word文档以及HTML输出。但是,将应用程序部署到RStudio Connect之后,它不会呈现HTML输出(错误输出)。我的本地库中是否有允许HTML输出的特定程序包?

RStudio Connect的错误日志如下。

Warning: Error in : Functions that produce HTML output found in document targeting docx output.
05/30 15:36:18.075
Please change the output type of this document to HTML. Alternatively, you can allow
05/30 15:36:18.075
HTML output in non-HTML formats by adding this option to the YAML front-matter of
05/30 15:36:18.075
your rmarkdown file:

同样,HTML输出在本地不是问题,我认为未在connect上安装的特定软件包是罪魁祸首。

Server file: Linked to an action button in UI File.
output$scorecard <- downloadHandler(
        # For PDF output, change this to "report.pdf"
        filename = "Supplier_Scorecard.docx",
        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(), "scorecard.Rmd")
            #file.copy("scorecard.Rmd", tempReport, overwrite = TRUE)

            # Set up parameters to pass to Rmd document
            params <- list(supplier = input$which.supplier, names = input$supplier.name, street = input$supplier.street,
                           citystate = input$supplier.citystate, datas = scarred, one = Two[1], two = Two[2], three = Two[3])

            # 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("scorecard.Rmd", output_file = file,
                              word_document(reference_docx = "styles-reference-word.docx",
                                            fig_height = 4),
                              params = params,
                              envir = new.env(parent = globalenv())
            )
        }
    )

YAML

title: "Supplier Scorecard"
output: word_document
params:
  citystate: NA
  datas: NA
  date: !r format(Sys.Date(), "%b-%d-%Y")
  names: NA
  one: NA
  street: NA
  supplier: NA
  three: NA
  two: NA

当我在本地运行闪亮的应用程序时,我没有任何问题。渲染到Word文档,可以看到HTML输出。

同样,在RStudio中,将其错误输出到我的日志中的以下消息。

Warning: Error in : Functions that produce HTML output found in document targeting docx output.
05/30 15:36:18.075
Please change the output type of this document to HTML. Alternatively, you can allow
05/30 15:36:18.075
HTML output in non-HTML formats by adding this option to the YAML front-matter of
05/30 15:36:18.075
your rmarkdown file:

0 个答案:

没有答案