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

Flexdashboard/R Markdown布局:Performance标签页图表与表格并排实现

解决方案

当然可以实现这个效果!在flexdashboard的标签页内部,你可以通过嵌套**列布局(Column)**来让表格和ggplot图表相邻显示。核心思路是把原本放在同一个代码块里的表格和图表,拆分到两个独立的列区域中,下面是修改后的完整代码:

title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    runtime: shiny
    source_code: embed
    theme: cosmo
    storyboard: TRUE
---
```{r setup, include=FALSE}
library(flexdashboard)
library(readxl)
library(tidyverse)
library(ggplot2)
library(shiny)
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
Performance <- structure(list(Mills = c("Mill-A", "Mill-B", "Mill-C", "Mill-D", "Mill-E"), Performance = c(0.5, 0.4, 0.2, 0.9, 0.4)), row.names = c(NA, -5L), class = "data.frame")

Summary =================
Inputs {.sidebar}

Column {data-width=300}

Chart A

Row {.tabset .tabset-fade}

Performance {data-height=2000}

Row

Column {data-width=400}

dt %>% kable() %>% kable_styling()

Column {data-width=600}

ggplot(data = Performance,aes(x=Mills,y=Performance))+geom_bar(stat = "identity")

Parameters {data-height=1000}

Forecasting =================
Inputs {.sidebar}

Column {data-height=1000}

Chart A

### 关键说明
- 在`Performance`标签页内部,我们新增了一个`Row`布局容器,然后在里面定义了两个`Column`子区域
- 通过`data-width`参数可以调整两个区域的宽度比例(示例中表格占400单位宽度,图表占600),你可以根据实际需求修改这个数值
- 把表格和图表的代码分别放到对应列的代码块中,它们就会自动并排显示在同一行里

内容的提问来源于stack exchange,提问作者Dev P
相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:17:54