如何在 rmarkdown html_document 中对齐 table 和绘图
How to align table and plot in rmarkdown html_document
如何对齐 kable table 使其与 rmarkdown html_document 中的 ggplot2 图相邻?
Foo.Rmd
---
title: "Foo"
output: html_document
---
```{r setup, include=FALSE}
library(ggplot2)
library(knitr)
library(kableExtra)
```
# Table next to plot
```{r echo = FALSE}
kable(head(iris)) %>%
kable_styling(bootstrap_options = "striped", full_width = F)
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
```
我尝试遵循解决方案 但无济于事。
@ErrantBard 在这里提供了一个很好的解决这个问题的方法:。请访问并点赞!
我正在复制我的答案中的解决方案,以展示它如何与您的示例一起使用,并提供解决方案的图像。
要更好地了解这些 div
标签的工作原理,请详细了解 bootstrap 库。这是一个很好的link:https://getbootstrap.com/docs/4.1/layout/grid/
---
title: "Foo"
output: html_document
---
```{r setup, include=FALSE}
library(ggplot2)
library(knitr)
library(kableExtra)
```
# Table next to plot
<div class = "row">
<div class = "col-md-6">
```{r echo=FALSE}
kable(head(iris)) %>%
kable_styling(bootstrap_options = "striped", full_width = FALSE, position="left")
```
</div>
<div class = "col-md-6">
```{r echo=FALSE}
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
```
</div>
</div>
如何对齐 kable table 使其与 rmarkdown html_document 中的 ggplot2 图相邻?
Foo.Rmd
---
title: "Foo"
output: html_document
---
```{r setup, include=FALSE}
library(ggplot2)
library(knitr)
library(kableExtra)
```
# Table next to plot
```{r echo = FALSE}
kable(head(iris)) %>%
kable_styling(bootstrap_options = "striped", full_width = F)
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
```
我尝试遵循解决方案
@ErrantBard 在这里提供了一个很好的解决这个问题的方法:。请访问并点赞! 我正在复制我的答案中的解决方案,以展示它如何与您的示例一起使用,并提供解决方案的图像。
要更好地了解这些 div
标签的工作原理,请详细了解 bootstrap 库。这是一个很好的link:https://getbootstrap.com/docs/4.1/layout/grid/
---
title: "Foo"
output: html_document
---
```{r setup, include=FALSE}
library(ggplot2)
library(knitr)
library(kableExtra)
```
# Table next to plot
<div class = "row">
<div class = "col-md-6">
```{r echo=FALSE}
kable(head(iris)) %>%
kable_styling(bootstrap_options = "striped", full_width = FALSE, position="left")
```
</div>
<div class = "col-md-6">
```{r echo=FALSE}
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
```
</div>
</div>