Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
| 2 | % Please edit documentation in R/add_header_above.R |
| 3 | \name{add_header_above} |
| 4 | \alias{add_header_above} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 5 | \title{Add a header row on top of current header} |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 6 | \usage{ |
Hao Zhu | 32f43f7 | 2017-06-20 18:24:54 -0400 | [diff] [blame^] | 7 | add_header_above(kable_input, header = NULL, bold = F, italic = F) |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 8 | } |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 9 | \arguments{ |
| 10 | \item{kable_input}{Output of `knitr::kable()` with `format` specified} |
| 11 | |
| 12 | \item{header}{A (named) character vector with `colspan` as values. For |
| 13 | example, `c(" " = 1, "title" = 2)` can be used to create a new header row |
| 14 | for a 3-column table with "title" spanning across column 2 and 3. For |
| 15 | convenience, when `colspan` equals to 1, users can drop the ` = 1` part. |
| 16 | As a result, `c(" ", "title" = 2)` is the same as `c(" " = 1, "title" = 2)`.} |
Hao Zhu | 32f43f7 | 2017-06-20 18:24:54 -0400 | [diff] [blame^] | 17 | |
| 18 | \item{bold}{A T/F value to control whether the text should be bolded.} |
| 19 | |
| 20 | \item{italic}{A T/F value to control whether the text should to be emphasized.} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 21 | } |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 22 | \description{ |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 23 | Tables with multiple rows of header rows are extremely useful |
| 24 | to demonstrate grouped data. This function takes the output of a `kable()` |
| 25 | function and adds an header row on top of it. This function can work with |
| 26 | both `HTML` and `LaTeX` outputs |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 27 | } |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 28 | \examples{ |
| 29 | x <- knitr::kable(head(mtcars), "html") |
| 30 | # Add a row of header with 3 columns on the top of the table. The column |
| 31 | # span for the 2nd and 3rd one are 5 & 6. |
| 32 | add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6)) |
| 33 | |
| 34 | } |