Quantcast
Channel: Active questions tagged kable - Stack Overflow
Viewing all articles
Browse latest Browse all 108

Two column headers with same borders

$
0
0

I'd love to have consistent borders on my kable table

Here's my data frame:

df1 <- data.frame(inst = c("A", "B", "C", "D", "E", "F", "G"),                    year_1_type1 = c(1,5,3,8,7,9,4),                    year_2_type1 = c(5,7,8,3,5,2,6),                    year_1_type2 = c(1,5,3,8,7,9,4),                    year_2_type2 = c(5,7,8,3,5,2,6))

And here is my table:

enter image description here

And here is the code:

 df1  %>%     kbl(caption = '<b>Table 5</b>-Comparison of Types and Years', align='l',           col.names = c("inst", "year 1", "year 2", "year 1", "year 2")) %>%     kable_classic(full_width = T, html_font = "Arial Narrow") %>%      kable_styling() %>%     add_header_above(c(" " = 1, "Type 1" = 2, "Type 2"=2), align = "l", extra_css ="border-left: 1px solid;")

I definitely want the border to the left of Type 1 and Type 2 but it would be nice if it extended to the left of year 1 I tried adding extra_css ="border-left: 1px solid;" after the col.names function but that didn't work. Does anyone know how to add these borders?


Viewing all articles
Browse latest Browse all 108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>