我有一个在代码块外部包含内联r代码的表,如下所示:
---
title: "test"
output:
html_document:
theme: flatly
---
```{r}
data(mtcars)
```
| Col1 | Col2 |
|------ |---------------- |
| N | `r nrow(cars)` |
但是,这几乎无法控制表格的外观。我真正想要的是这样的东西:
---
title: "test"
output:
html_document:
theme: flatly
---
```{r}
library(dplyr)
library(knitr)
library(kableExtra)
data(mtcars)
```
```{r}
Col1 <- c("N", "Col")
Col21 <- nrow(cars)
Col22 <- length(cars)
kable(data.frame(Col1, Col2 = c(Col21, Col22))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
```
我知道这将涉及使用CSS。我有什么选择?在代码块内部重新创建表(如示例中所示)有点繁琐。有没有办法在块外应用与kableextra::kable_styling(bootstrap_options = c("striped", "hover"))
相同的外观?