微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我的 Shiny App 在我调用 Markdown 时删除了它的内容并且不保存为 pdf

如何解决我的 Shiny App 在我调用 Markdown 时删除了它的内容并且不保存为 pdf

我正在尝试创建一个闪亮的应用程序,该应用程序调用 Markdown 以下载包含金融股票代码的文本条目的 PDF

但是当我按下下载按钮时,降价内容删除

此外,当我单击生成报告时,它会打开一个文件资源管理器并要求我保存一个名为报告的文件,但没有生成任何内容。在控制台中,我收到以下消息:

输出创建:Reporte_consulta_tu_accion_andes.pdf

这是我的闪亮代码

 library(shiny) 
  library(quantmod)
  library(xts)
  library(formattable)
  library(TTR)
  library(stringi)
  library(docxtractr)
  library(shinyWidgets)
  library(shinythemes)
  library(tidyverse)
  library(tidyquant)
  library(plotly)
  library(ggplot2)
  library(knitr)
  shinyApp(
      ui = fluidPage(
          textInput("text","generar"),downloadButton("report","Generate report"),textoutput("a")
          
          
      ),server = function(input,output) {
          
        #setwd("C:/Users/SAMUELYAICEL/Desktop/Escritorio/Blog_data_info/blog_data_info")
          output$report <- downloadHandler(
              # For PDF output,change this to "report.pdf"
              filename = "Reporte_consulta_tu_accion_andes.pdf",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).
                  wd <- getwd()
                  tempReport <- file.path(wd,"Reporte_consulta_tu_accion_andes.rmd")
                
                  file.copy("Reporte_consulta_tu_accion_andes.pdf",tempReport,overwrite = TRUE)
                  
                  # Set up parameters to pass to Rmd document
                  params <- list(text = input$text)
                  output$a <- reactive(input$text)
                  # 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,output_format = pdf(),params = params,envir = new.env(parent = globalenv())
                  )
              }
          )
      }
  )
  
  shinyApp(ui = ui,server = server)

还有我的 Rmd 文件

---
output: pdf_document
fontsize: 11pt
geometry: margin=2cm
number_sections: true
header-includes:
  - \usepackage{fancyhdr}
  - \usepackage{lipsum}
  - \pagestyle{fancy}
  - \fancyhead[RO,LE]{Andes }
  - \fancyfoot[RO,LE]{@Andes}
params:
  text: NA
---

```{r,include=FALSE}
options(tinytex.verbose = TRUE)
```

```{r}
params[["text"]]
```

```{r setup,include=FALSE}
library(quantmod)
library(xts)
library(formattable)
library(TTR)
library(stringi)
library(docxtractr)
library(shinyWidgets)
library(shinythemes)
library(tidyverse)
library(tidyquant)
library(plotly)
library(ggplot2)
library(knitr)
ticker <- params[["text"]]
prices3 <- getSymbols(params[["text"]])
prices3
what_metrics <- yahooQF(c("Name","Symbol","Market Capitalization","P/E ratio","Dividend Yield",#"Percent Change From 20-day Moving Average","Percent Change From 50-day Moving Average","Percent Change From 200-day Moving Average"))
Compania  <- getQuote(prices3,what=what_metrics)
```

我是初学者,谁能告诉我我做错了什么?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。