I'm trying to rotate table column headers in RMarkdown. Since I don't have an understanding of CSS my attempts so far have proven to be futile.
So, how can I rotate the table column headers?
Here is a minimal example for a table in RMarkdown:
---
title: "Untitled"
output:
html_document:
df_print: paged
style: ./Table.css
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(kableExtra)
library(knitr)
```
<div class="table-header-rotated">
```{r test, result="asis"}
kable(head(mtcars), "html")
```
</div>
And the CSS file was made from the code presented here: https://codepen.io/chriscoyier/pen/Fapif
Can anyone give me a hint?
You could just use kable_styling()
and row_spec()
from kableExtra
.
---
title: "Untitled"
output:
html_document:
df_print: paged
style: ./Table.css
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(kableExtra)
library(knitr)
```
<div class="table-header-rotated">
```{r test, result="asis"}
kable(head(mtcars), "html") %>%
kable_styling("striped", full_width = F) %>%
row_spec(0, angle = -45)
```
yields:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With