如何避免表(数据表)在flexdashboard容器中被其他文本截断?

时间:2019-05-22 12:48:07

标签: r markdown r-markdown dt flexdashboard

当数据表对象上方有文本时,该表将被截断并且分页不再可见。

是否可以将数据表的大小调整为适合一个flexdashboard容器?

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

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

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r, results='asis'}
cat("This is a text\n\nThis is a text")
```

```{r}
mtcars %>% datatable(options = list(dom = 'tp'))
```

1 个答案:

答案 0 :(得分:1)

您有一些选择。您可以使用vertical_layout: scroll。这样一来,分页功能就可以正常工作,同时将文本与表格保存在同一容器中。

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

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

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r, results='asis'}
cat("This is a text\n\nThis is a text")
```

```{r}
mtcars %>% datatable(options = list(dom = 'tp'))
```

或者,您可以对文本和表格使用单独的容器。如果这样做,您可能希望使用{data-height}来设置容器的高度。

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

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

Column {data-width=650}
-----------------------------------------------------------------------

### Text A {data-height=50}

```{r, results='asis'}
cat("This is a text\n\nThis is a text")
```

### Chart A

```{r}
mtcars %>% datatable(options = list(dom = 'tp'))
```