You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FlexDashboard结合Shiny无法渲染图表问题求助

Flexdashboard + Shiny 交互内容重复渲染/浏览器端空白问题解决

问题现象

  • 制作带Shiny交互的flexdashboard时,RStudio内首次渲染一切正常,但重新运行后图表、表格完全空白(标题、格式、下拉菜单显示正常,无任何报错信息)
  • 直接在浏览器中打开时,首次加载就出现同样的空白问题
  • 更新RStudio及所有相关包后问题依旧,仅能通过随机编辑代码(如删除再还原括号)临时解决,但浏览器端问题无法修复

问题复现简化代码

---
title: "Test Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
  runtime: shiny  # 错误位置:与output子项缩进对齐
---

```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(ggplot2)

Column {data-width=650}

Chart A

selectInput("n", "Number of points:", choices = c(10, 20, 30), selected = 10)
renderPlot({
  ggplot(mtcars, aes(wt, mpg)) + geom_point(size = input$n)
})
## 解决方案
问题根源在于YAML配置的缩进错误:**`runtime: shiny` 不能作为`output`的子项缩进对齐**,必须将其提升到与`title`、`output`同级的层级。

修正后的YAML配置:
```yaml
---
title: "Test Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
runtime: shiny  # 正确位置:与output同级,无额外缩进
---

内容的提问来源于stack exchange,提问作者Laura

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 03:15:27