gpt4 book ai didi

r - flexdashboard 导航栏中的下载按钮

转载 作者:行者123 更新时间:2023-12-03 20:49:58 25 4
gpt4 key购买 nike

我在 .navbar-right 中创建了一个下载按钮.
enter image description here
我想将该按钮链接到 downloadHandler()将根据包含仪表板图表 1 的“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()
```

最佳答案

弹性仪表板::弹性仪表板:
源代码:嵌入
需要在新行上的 source_code 之前缩进(点击返回),但我无法让它工作。 Here's more information.
哎呀,别介意对不起。请忽略。我看错了

关于r - flexdashboard 导航栏中的下载按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63376648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com