I am making a presentation in RMarkdown using ioslides. I am trying to add a table of text, and the first column is bold. I would like to either make both columns bold or both columns not bold.
For example, in this presentation, the x column is bold and the y column is not:
---
title: test
output: ioslides_presentation
---
##
| x | y |
---------
| 1 | 2 |
I have also tried making the table in a chunk of R code and using kableExtra
to make the second column bold, but then ioslides does not format the table nicely (and so in this case only the second column is bold, and the table does not look nice in the presentation). For example:
##
```{r, echo = FALSE}
library(kableExtra)
mat <- matrix(c(1,2), nrow = 1, dimnames = list(NULL, c('x', 'y')))
mat.kable <- kable(mat)
column_spec(mat.kable, 2, bold = TRUE)
```
You can "force" the second column to be bold. And putting a plus sign in the middle of the dashed line will give your table a proper header:
##
| x | y |
----+----
| 1 | **2** |
If using kableExtra
, it is better to use kable_styling
:
kable(mat) %>%
kable_styling(full_width = T, bootstrap_options = c("striped")) %>%
row_spec(0, font_size=30) # use row_spec to get control over your header. Header is row 0