blob: 820ac600481eccc6a236d63837f81b530e164728 [file] [log] [blame]
Hao Zhu67764aa2019-03-15 11:57:50 -04001---
2title: "xtable & kableExtra"
3author: "Hao"
4date: "2/13/2019"
5output: pdf_document
6---
7
8```{r setup, include=FALSE}
9knitr::opts_chunk$set(message = FALSE)
10```
11
12Recent versions of kableExtra (since 1.0) offers a function `xtable2kable`, which, as suggested by its name, turns a `xtable` object to a `kable` object so you can use functions in kableExtra after that. I tested some basic examples and it seem to work.
13
14```{r}
15library(xtable)
16library(kableExtra)
17
18xtable(mtcars[1:5, 1:5]) %>%
19 xtable2kable() %>%
20 column_spec(1, width = "5cm")
21```
22
23```{r}
24xtable(mtcars[1:5, 1:5], caption = "Some long caption") %>%
25 xtable2kable(caption.width = "10em") %>%
26 column_spec(1, color = "red")
27```
28
29
30