flexdashboard导航栏中的下载按钮 这是应用程序这是报告Rmd

问题描述

我在.navbar-right中创建了一个下载按钮。

enter image description here

我想将该按钮链接downloadHandler()函数,该函数将基于包含仪表板图表1的“ report.Rmd”生成一个.pdf报告。有人知道如何做到这一点吗?

我试图在导航栏中创建一个闪亮的下载按钮,但它始终会显示在其正下方。

这是应用程序

    ---
    title: "COVID-19 Dashboard"
    output: 
       flexdashboard::flex_dashboard:
        orientation: rows
        navbar:
          - { icon: "fa-download",href: "#",align: right }
        social: menu
    date: "`r Sys.Date()`"
    runtime: shiny
    ---

    ```{r setup,include=FALSE}
    library(flexdashboard)
    library(knitr)
    library(shiny)
    library(tidyverse)
    library(highcharter)

    mdc_c19 <- read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us- 
    counties.csv") %>% 
      filter(state == "Florida") %>% 
      filter(county == "Miami-Dade") %>% 
      filter(date >="2020-06-01" )

    thm <- 
      hc_theme(
        colors = c("#025930","#F27B35","#F24405","#d4bf95","#a2ad00","#A2B1BD"),chart = list(
          backgroundColor = "transparent",style = list(fontFamily = "sans-serif")
        ),xAxis = list(
          gridlinewidth = 1
        )
      )
    ```


   ```{r download}
    # Add download handling
     output$downLink <- downloadHandler(
      filename =paste0("ModelReport-",Sys.Date(),".pdf"),content = function(file) {
        to_save <- list(
           deaths = deaths()
        )
        readr::write_rds(to_save,"config_data.rds")
        rmarkdown::render("report.Rmd")
        #webshot::webshot("report.html",file = file)
    
      }
     )
Tab1
=====================================  

Row
-------------------------------------

### Chart 1


```{r}
deaths <- hchart(mdc_c19,"line",hcaes(x = date,y = deaths)) %>% 
   hc_add_theme(thm)
deaths
```

### Chart 2

```{r}
``` 

这是报告。Rmd

    ---
    title: "Dashboard Report"
    output:
      flexdashboard::flex_dashboard:
        orientation: rows
    ---


    ```{r}
    data <- readr::read_rds("config_data.RDS")
    data$deaths %>% print() 
    ```

解决方法

flexdashboard :: flexdashboard: source_code:嵌入

需要在新行的源代码之前缩进(按回车键),但是我无法使其工作。 Here's more information.

哎呀,没关系,对不起。请忽略。我看错了

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...