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 | ac7e70f | 2017-08-02 00:18:36 -0400 | [diff] [blame] | 7 | add_header_above(kable_input, header = NULL, bold = FALSE, italic = FALSE, |
| 8 | monospace = FALSE, escape = TRUE) |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 9 | } |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 10 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 11 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 12 | |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 13 | \item{header}{A (named) character vector with \code{colspan} as values. For |
| 14 | example, \code{c(" " = 1, "title" = 2)} can be used to create a new header row |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 15 | for a 3-column table with "title" spanning across column 2 and 3. For |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 16 | convenience, when \code{colspan} equals to 1, users can drop the \code{= 1} part. |
| 17 | As a result, \code{c(" ", "title" = 2)} is the same as \code{c(" " = 1, "title" = 2)}.} |
Hao Zhu | 32f43f7 | 2017-06-20 18:24:54 -0400 | [diff] [blame] | 18 | |
| 19 | \item{bold}{A T/F value to control whether the text should be bolded.} |
| 20 | |
| 21 | \item{italic}{A T/F value to control whether the text should to be emphasized.} |
Hao Zhu | ac7e70f | 2017-08-02 00:18:36 -0400 | [diff] [blame] | 22 | |
| 23 | \item{monospace}{A T/F value to control whether the text of the selected column |
| 24 | need to be monospaced (verbatim)} |
| 25 | |
| 26 | \item{escape}{A T/F value showing whether special characters should be |
| 27 | escaped.} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 28 | } |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 29 | \description{ |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 30 | Tables with multiple rows of header rows are extremely useful |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 31 | to demonstrate grouped data. This function takes the output of a \code{kable()} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 32 | function and adds an header row on top of it. This function can work with |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 33 | both \code{HTML} and \code{LaTeX} outputs |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 34 | } |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 35 | \examples{ |
| 36 | x <- knitr::kable(head(mtcars), "html") |
| 37 | # Add a row of header with 3 columns on the top of the table. The column |
| 38 | # span for the 2nd and 3rd one are 5 & 6. |
| 39 | add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6)) |
| 40 | |
| 41 | } |