I have almost got the perfect table for a Latex report I am drafting with the kable package in rMarkdown. One thing I can't get quite right is the vertical alignment of the collapsed rows.
Using the sample code from the kableExtra documentation reproduces my problem:
collapse_rows_dt <- data.frame(C1 = c(rep("a", 10), rep("b", 5)),
C2 = c(rep("c", 7), rep("d", 3), rep("c", 2), rep("d", 3)),
C3 = 1:15,
C4 = sample(c(0,1), 15, replace = TRUE))
kbl(collapse_rows_dt, booktabs = T, align = "c") %>%
column_spec(1, bold=T) %>%
collapse_rows(columns = 1:2, latex_hline = "custom", custom_latex_hline = 1:2, valign = "top")
This almost works, so close...but the vertical alignment is not consistent across the columns. This makes it unreadable when the table runs over multiple pages.
valign= "bottom" works perfectly though.