5

I have created a download button in the .navbar-right .

enter image description here

I would like to link that button to the downloadHandler() function that will generate a .pdf report based on the "report.Rmd" which contains Chart 1 of the dashboard. Does anyone know how to accomplish this?

I have attempted to create a Shiny download button in the navbar but it would always display right under it.

This is the app

    ---
    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}
``` 

This is report.Rmd

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


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

1 Answers1

0

flexdashboard::flexdashboard: source_code: embed

Need to indent before source_code on a new line (hit return), but I could not get it to work. Here's more information.

Whoops, never mind sorry. Please disregard. I misread

g. garcia
  • 1
  • 1