如何从 R 闪亮的应用程序制作 pdf 报告

问题描述

我想制作一份在 Shiny App 中进行的分析的 pdf 报告。基本上,我制作了一个统计应用程序,您可以在其中上传 excel 文件,选择变量,然后运行一些线性模型,然后对模型的残差进行一些统计测试,因此对于此分析,我想要一份 pdf 报告显示了应用程序中的所有输出和注释(包括选定的变量和选定变量后数据框的预览)。我在互联网上创建了材料,但我无法弄清楚。主要问题是我必须打开一个外部 RMD 文件,我应该将什么作为代码输入?我试图编写这样的代码

output$downloadReport <- downloadHandler(
    filename = function() {
      paste0('report_',Sys.Date(),'.',switch(
        input$report_format,PDF = 'pdf',HTML = 'html',Word = 'docx'
      ))
    },content = function(file) {
      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')

      library(rmarkdown)
      out <- render(input = 'report.Rmd',output_format = switch(
                      input$report_format,PDF = pdf_document(),HTML = html_document(),Word = word_document()
                    )
      )
      file.rename(out,file)
      
      RawData()
      Probay()
      Conclusiony()
      
      
    }
  )

我很确定这是不正确的。 RawData 是选择变量后数据框的输出,Probay 是统计测试的输出,Concluionsy 是测试的结论,基本上只是文本。 提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)