shiny - 在 flexdashboard 中下载图表
问题描述
我正在尝试使用 flex 仪表板的输入列中的下载按钮来下载呈现为 *.pdf 的图表集合。整个仪表板工作正常,下载按钮正常呈现;但是,当我单击下载按钮时,下载的文件不包含预期的图表。当我的 Mac 尝试打开文件时,我收到的警告是文件可能已损坏,或者它是 Preview(或 Acrobat)无法识别的表单。以下是我的代码的高度编辑形式,其中包含有问题的部分。关于如何在 flexdashboard 中下载图表作为在 Shiny 中下载图表的任何指导?
---
title: "My Model"
runtime: shiny
output:
flexdashboard::flex_dashboard:
theme: cerulean
vertical_layout: scroll
orientation: rows
---
```{r global, include=FALSE}
library(shiny)
library(shinyBS)
library(shinyWidgets)
library(flexdashboard)
library(tidyverse)
library(readxl)
library(knitr)
library(RColorBrewer)
source("MLHS_Distributions.R")
source("interp.R")
source("tooltips.R")
```
```{r Inputs}
downloadButton("downlaodReport","Price Comparision Report")
downloadHandler(filename = function() {
filename = paste0("ModelReport-", Sys.Date(), ".pdf")
},
content = function(file) {
pdf(file, width = 8.5, height = 6.14)
renderPrint({output$gg.prob.win.price()})
dev.off()
}
)
```
```{r priceProbWinChart}
renderPlot({
gg.prob.win.price <- --ggplot code--
plot(gg.prob.win.price)
})
```
解决方案
推荐阅读
- python - `--context` 的 Kubernetes API 等价物是什么?
- html - 更新烧瓶中的 SQL 查询不适用于浮点/小数点
- python - Python - 当您不知道需要多少次时如何使用多线程和队列
- java - 使用 apache commons 时删除 csv 文件开头的双引号
- java - Spring Repository 自动生成方法:按给定的顶部编号选择 + 按字段 desc 排序
- postgresql - 如何恢复当前正在写入 master 且尚未归档的 wal 文件?
- arrays - 使用 jq 嵌套数组值
- c# - 将进程输出重定向到 JSON
- python-3.x - PyTorch:“TypeError:在 DataLoader 工作进程 0 中捕获 TypeError。”
- php - Can't get an array returning from a class function