Reputation: 19107
I'm using Rmarkdown
to generate an HTML output, where two kables
are placed side by side using kable::kables
. However, there's an extra line above the side-by-side kables that I would like to remove. I've read the documentation of kableExtra, but seems like they didn't cover this issue.
The horizontal line that I would like to remove is indicated by the red arrow below.
Here's my Rmarkdown
code for your reference:
---
title: "Untitled"
author: "benson23"
output:
html_document:
theme: default
toc: yes
toc_depth: 4
toc_float: true
code_folding: hide
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(rmarkdown)
library(kableExtra)
library(knitr)
```
## Help with Kable
As you can see, there's an extra line above the aligned tables, which I would like to remove.
```{r kable_extra_line}
df1 <- tibble(Dummy = c(90748, 91006, 90748, 91006),
A = c(0, 6, 1, 110),
B = c(8, 0, 339, 0),
C = c(6, 7, 909, 309),
D = c(0, 0, 0, 0))
df2 <- tibble(Dummy = c(90748, 91006, 90748, 91006),
A = c(0, 901, 0, 50),
B = c(0, 1, 122, 0),
C = c(1847, 1, 754, 625),
D = c(1, 0, 0, 0))
kables(list(
kable(df1) %>%
kable_styling(bootstrap_options = c("striped", "bordered"),
full_width = F) %>%
row_spec(0, bold = T) %>%
pack_rows("Pack some rows here", 1, 2,
label_row_css = "background-color: #666; color: #fff;") %>%
pack_rows("Pack some rows here", 3, 4,
label_row_css = "background-color: #666; color: #fff;"),
kable(df2) %>%
kable_styling(bootstrap_options = c("striped", "bordered"),
full_width = F) %>%
row_spec(0, bold = T) %>%
pack_rows("Pack some rows here", 1, 2,
label_row_css = "background-color: #666; color: #fff;") %>%
pack_rows("Pack some rows here", 3, 4,
label_row_css = "background-color: #666; color: #fff;")
)) %>%
kable_styling()
```
It'd be great if you have any idea on how to remove the line!
Upvotes: 0
Views: 1093
Reputation: 10637
You can add the css .kable_wrapper { border: hidden;}
:
---
title: "Untitled"
author: "benson23"
output:
html_document:
theme: default
toc: yes
toc_depth: 4
toc_float: true
code_folding: hide
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(rmarkdown)
library(kableExtra)
library(knitr)
```
<style>
.kable_wrapper {
border: hidden;
}
</style>
## Help with Kable
As you can see, there's an extra line above the aligned tables, which I would like to remove.
```{r kable_extra_line}
df1 <- tibble(Dummy = c(90748, 91006, 90748, 91006),
A = c(0, 6, 1, 110),
B = c(8, 0, 339, 0),
C = c(6, 7, 909, 309),
D = c(0, 0, 0, 0))
df2 <- tibble(Dummy = c(90748, 91006, 90748, 91006),
A = c(0, 901, 0, 50),
B = c(0, 1, 122, 0),
C = c(1847, 1, 754, 625),
D = c(1, 0, 0, 0))
kables(list(
kable(df1) %>%
kable_styling(bootstrap_options = c("striped", "bordered"),
full_width = F) %>%
row_spec(0, bold = T) %>%
pack_rows("Pack some rows here", 1, 2,
label_row_css = "background-color: #666; color: #fff;") %>%
pack_rows("Pack some rows here", 3, 4,
label_row_css = "background-color: #666; color: #fff;"),
kable(df2) %>%
kable_styling(bootstrap_options = c("striped", "bordered"),
full_width = F) %>%
row_spec(0, bold = T) %>%
pack_rows("Pack some rows here", 1, 2,
label_row_css = "background-color: #666; color: #fff;") %>%
pack_rows("Pack some rows here", 3, 4,
label_row_css = "background-color: #666; color: #fff;")
)) %>%
kable_styling()
```
Upvotes: 1