我已经在
我已经尝试在导航栏中创建一个Shiny下载按钮,但它总是显示在其下方。
.navbar-right
中创建了一个下载按钮。
我希望将该按钮链接到downloadHandler()
函数,该函数将基于仪表板中的"report.Rmd"生成.pdf报告。有人知道如何实现吗?我已经尝试在导航栏中创建一个Shiny下载按钮,但它总是显示在其下方。
这是应用程序
---
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}
```
这是report.Rmd
---
title: "Dashboard Report"
output:
flexdashboard::flex_dashboard:
orientation: rows
---
```{r}
data <- readr::read_rds("config_data.RDS")
data$deaths %>% print()
```