flexdashboard 元素上的下拉菜单?

问题描述 投票:0回答:1

有没有一种方法可以向 Flexdashboard 上的一个元素添加下拉菜单,以便用户可以选择显示哪个表格?在这个例子中,我有 3 个小表,每个物种一个,但我想一次只显示一张表,并且能够使用下拉菜单更改显示哪一个表。我尝试使用选项卡,但还有另一个表应该始终显示在列中,并且找不到解决方法。 非常感谢!

---
title: "Titulo"
output: 
  flexdashboard::flex_dashboard
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(dplyr)

```

Column {data-width=500}
-----------------------------------------------------------------------

### Small table 1

```{r, echo=FALSE}

iris %>% filter(Species=="setosa")

```


### Small table 2

```{r,echo=FALSE}

iris %>% filter(Species=="virginica")

```


### Small table 3

```{r, echo=FALSE}

iris %>% filter(Species=="versicolor")

```

### Not related table

```{r, echo=FALSE}

cars

```

Column {data-width=500}
-----------------------------------------------------------------------

### BIG PLOT

```{r}

plot(cars, pch = 20)

```
r dropdown flexdashboard
1个回答
0
投票

flexdashboard
的文档不是很有帮助,但是查看示例,似乎在标题上包含
runtime: shiny
可以让您摆脱使用任何
shiny
输入和渲染功能的麻烦:

---
title: "Titulo"
output: 
  flexdashboard::flex_dashboard
runtime:
  shiny
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(dplyr)
```

Column {data-width=500}
-----------------------------------------------------------------------

### Small table 

```{r, echo=FALSE}
selectInput("small_table", "Table to show:",
            c("setosa","virginica","versicolor"))
```

```{r, echo=FALSE}
renderTable(
  iris %>% filter(Species == input$small_table)
)
```

### Not related table

```{r, echo=FALSE}
cars
```

Column {data-width=500}
-----------------------------------------------------------------------

### BIG PLOT

```{r}
plot(cars, pch = 20)
```
© www.soinside.com 2019 - 2024. All rights reserved.