haozhu233 / kableExtra

Construct Complex Table with knitr::kable() + pipe.
https://haozhu233.github.io/kableExtra/
Other
688 stars 147 forks source link

Borders in knitr::kable for extra headers #239

Open dkStevensNZed opened 6 years ago

dkStevensNZed commented 6 years ago

This may be asking too much, but I've recently used add_header_above to add a multicolumn header to a table. I'd like to separate two headers in the same row with a vertical border. I've successfully added the border to the table body and to the column names (col.names), but the extra header confounds me. t6 is a 12 column x 6 row table and the following creates the table.

col.names <- c('Year','Beginning\nUnrecovered\nBalance', 'Interest on\nUnrecovered\nBalance', 'Cash Flow','Recovered\nAmount', 'Ending\nUnrecovered\nBalance') col.names <- c(col.names,col.names) hdr.above <- c('Basis: Unrecovered balance'=6,'Basis: Initial Principal'=6)

x <- knitr::kable(t6,format=TableFormat,align=a, col.names=c(col.names,col.names),caption='ROR Results', booktabs=T, escape=F) %>% kable_styling(bootstrap_options=c('striped','hover','condensed','responsive'), position='center',latex_options = "hold_position", font_size = font.size,full_width=F) %>% column_spec(7,border_left=T) hdr.above.2 <- NULL x %>% add_header_above(hdr.above,align='l') %>% cline(c(2,5))

The pipe to column_spec(7,border_left=T) draws a vertical border in the main body and in the column names row. The extra header from add_header_above(...) has no border. Is there a way to add one using kable?

haozhu233 commented 6 years ago

I would say there is no solution for this at least right now. :P

gabrielacaesar commented 4 years ago

Hi @haozhu233! Are we still without solution for this?