R flexdashboard没有在tabset中显示我的所有数据表

时间:2018-06-12 16:13:22

标签: r datatable r-markdown dt flexdashboard

我有以下代码使用R和flexdashboard,当我渲染我的页面时,只显示df1,我可以看到df2的begening但是它不完整。

我看不到整个html页面的滚动条,所以我可以向下滚动查看df2和df3

任何有关此问题的想法?

谢谢!

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

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


### Chart A

```{r}
datatable(df1, filter ='top')
```

```{r}
datatable(df2, filter ='top')
```

```{r}
datatable(df3, filter ='top')
```

编辑:

解决我的问题的另一个解决方案是不在页面中的标签集中的以下布局

enter image description here

我不知道到目前为止是否可以使用Flexdashboard完成此操作!

谢谢:)

1 个答案:

答案 0 :(得分:1)

我相信flexdashboard目前的限制条件不允许您在一个标题下显示多个数据表(DT)。

相反,您可以考虑使用不同的布局。两列布局怎么样?

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

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

```{r}
df1 <- data.frame(
  x = rnorm(100),
  y = rnorm(100)
)

df2 <- data.frame(
  q = rnorm(100),
  p = rnorm(100)
)

df3 <- data.frame(
  r = rnorm(100),
  s = rnorm(100)
)
```

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

### Chart A

```{r}
datatable(df1, filter ='top')
```

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

### Chart B

```{r}
datatable(df2, filter ='top')
```

### Chart C

```{r}
datatable(df3, filter ='top')
```

编辑:

根据OP的要求,您可以在标签集中包含每个数据表,每个标签一个。像这样:

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
---

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

```{r}
df1 <- data.frame(
  x = rnorm(100),
  y = rnorm(100)
)

df2 <- data.frame(
  q = rnorm(100),
  p = rnorm(100)
)

df3 <- data.frame(
  r = rnorm(100),
  s = rnorm(100)
)
```

Row {.tabset .tabset-fade}
-------------------------------------

### Chart A

```{r}
datatable(df1, filter ='top')
```

### Chart B

```{r}
datatable(df2, filter ='top')
```

### Chart C

```{r}
datatable(df3, filter ='top')
```

有关flexdashboard布局的更多信息,请转到RStudio的website