In my Rmarkdown reports I use package arsenal's tableby() function to build a table, which I then push through knitr's kable() and kableExtra's kable_styling() to create nice-looking tables in a Rmarkdown HTML document. I have many tables and would like the tables to print as condensed as possible in height, i.e., with minimal row height.
To minimize the row height, I've tried decreasing the font_size, applying the bootstrap_options = c("condensed"), and changing the CSS for table cell padding.
The problem I encounter is that the indentations/bullet points in the tableby object seem to create an extra blank space/line below the text in that row.
I'd prefer to continue using kable/kable_extra as it's what I use throughout my Rmarkdown documents, but I'm open to alternatives that work well with arsenal's tableby tables.
Below is what I've tried:
---
title: "Untitled"
output: html_document
---
# In a CSS chunk
table, th, td {
padding-top: 0px !important;
padding-bottom: 0px !important;
vertical-align: middle;
}
# Chunck options
knitr::opts_chunk$set(echo = TRUE, results = 'asis')
# Packages
library(dplyr)
library(knitr)
library(kableExtra)
library(arsenal)
# Create table object
my_tbl <- tableby(arm ~ age + sex + race + ps + bmi,
data= mock_df, test=FALSE, total=FALSE)
# Push table object through kable and kable_styling
my_tbl %>%
summary(text=TRUE, digits.pct=1, digits=1) %>%
kable() %>%
kable_styling(full_width = FALSE, bootstrap_options = c("condensed"), font_size = 12) %>%
row_spec(2:3, bold = F, extra_css = 'vertical-align: middle !important;')
Below is the result. The rows with the variable names ("Age in years", "sex", "ps") have the row height I'm hoping for, but the rows that start with bullet points seem to have an extra white line or space below. To see where the problem lies I've set vertical alignment in the 2nd and 3rd row to "middle", which only worked for the 2nd, 3rd, and 4th columns, but not the first column with the bullet point.
Any help on getting rid of white space below bullet-point rows is much appreciated.

