r - 将文字描述放在 kable 旁边

标签 r r-markdown knitr kable kableextra

已关注 this example ,这就是我所拥有的

# iris
This section is about the iris dataset
```{r, echo=FALSE, message=FALSE, warning=FALSE}
kable(head(iris[, 1:2]), format = "html") %>%
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE, position = "float_right")
```

# mtcars
This section is about the mtcars dataset
```{r, echo=FALSE, message=FALSE, warning=FALSE}
kable(head(mtcars[, 1:2]), format = "html") %>%
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE, position = "float_right")
```

但是输出看起来像这样:

enter image description here

如何使mtcars部分出现在iris部分下方?

最佳答案

我猜kableExtra尚不提供此类功能。

但是,您可以解析为 html,并轻松执行以下操作:

---
title: "hi"
author: "me"
date: "March 23, 2018"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
library(knitr)
library(kableExtra)
options(knitr.table.format = "html")
```

```{r}
kable(head(iris[, 1:2])) %>%
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE, position = "float_right")
```
# iris
This section is about the iris dataset.

This could be a whole paragraph.
<p style="clear: both"></p>

```{r}
kable(head(mtcars[, 1:2])) %>%
  kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE, position = "float_right")
```
# mtcars
This section is about the mtcars dataset

相关位是<p style="clear: both"></p>

关于r - 将文字描述放在 kable 旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49457625/

相关文章:

r - R中的线性插值(lm),奇怪的行为

html - 如何在 R 中的 print() 中隐藏 [1]

r - kable 显示 html 代码而不是 html 表

r - 在 Rmarkdown 中保存导航栏 Shiny 应用程序

r - 如何在 RStudio 的 ioslides 中为每张幻灯片添加 Logo

latex - 在Knitr中,如何使用Latex中的\textwidth设置图形宽度

r - 多路交互 : easy way to get numerical coefficient estimates?

r wordcloud 外部 ttf vfont 无法识别

r - 创建一个包含给定日期和时间列的数据框

r - 设置要在输出中显示的小数位数