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 | 76f0eb6 | 2018-09-15 12:38:33 -0400 | [diff] [blame^] | 7 | add_header_above(kable_input, header = NULL, bold = FALSE, |
| 8 | italic = FALSE, monospace = FALSE, underline = FALSE, |
| 9 | strikeout = FALSE, align = "c", color = NULL, background = NULL, |
| 10 | font_size = NULL, angle = NULL, escape = TRUE, line = TRUE) |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 11 | } |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 12 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 13 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 14 | |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 15 | \item{header}{A (named) character vector with \code{colspan} as values. For |
| 16 | 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] | 17 | 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] | 18 | convenience, when \code{colspan} equals to 1, users can drop the \code{= 1} part. |
| 19 | 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] | 20 | |
| 21 | \item{bold}{A T/F value to control whether the text should be bolded.} |
| 22 | |
| 23 | \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] | 24 | |
| 25 | \item{monospace}{A T/F value to control whether the text of the selected column |
| 26 | need to be monospaced (verbatim)} |
| 27 | |
Hao Zhu | 76f0eb6 | 2018-09-15 12:38:33 -0400 | [diff] [blame^] | 28 | \item{underline}{A T/F value to control whether the text of the selected row |
| 29 | need to be underlined} |
| 30 | |
| 31 | \item{strikeout}{A T/F value to control whether the text of the selected row |
| 32 | need to be stricked out.} |
| 33 | |
Hao Zhu | 3465b50 | 2018-04-02 22:41:46 -0400 | [diff] [blame] | 34 | \item{align}{A character string for cell alignment. For HTML, possible values could |
| 35 | be \code{l}, \code{c}, \code{r} plus \code{left}, \code{center}, \code{right}, \code{justify}, \code{initial} and \code{inherit} |
| 36 | while for LaTeX, you can only choose from \code{l}, \code{c} & \code{r}.} |
| 37 | |
Hao Zhu | 76f0eb6 | 2018-09-15 12:38:33 -0400 | [diff] [blame^] | 38 | \item{color}{A character string/vector for text color. Here please pay |
| 39 | attention to the differences in color codes between HTML and LaTeX.} |
| 40 | |
| 41 | \item{background}{A character string/vector for background color. Here please |
| 42 | pay attention to the differences in color codes between HTML and LaTeX. Also |
| 43 | note that in HTML, background defined in cell_spec won't cover the whole |
| 44 | cell.} |
| 45 | |
| 46 | \item{font_size}{A numeric input/vector for font size. For HTML, you can also use |
| 47 | options including \code{xx-small}, \code{x-small}, \code{small}, \code{medium}, \code{large}, |
| 48 | \code{x-large}, \code{xx-large}, \code{smaller}, \code{larger}, \code{initial} and \code{inherit}.} |
| 49 | |
| 50 | \item{angle}{0-360, degree that the text will rotate.} |
| 51 | |
Hao Zhu | ac7e70f | 2017-08-02 00:18:36 -0400 | [diff] [blame] | 52 | \item{escape}{A T/F value showing whether special characters should be |
| 53 | escaped.} |
Hao Zhu | 68b5bbf | 2018-03-26 11:30:34 -0400 | [diff] [blame] | 54 | |
| 55 | \item{line}{A T/F value to control whether a line will appear underneath the |
| 56 | header} |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 57 | } |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 58 | \description{ |
Hao Zhu | f7994dd | 2017-02-27 16:58:42 -0500 | [diff] [blame] | 59 | Tables with multiple rows of header rows are extremely useful |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 60 | to demonstrate grouped data. This function takes the output of a \code{kable()} |
Hao Zhu | e7c8f70 | 2017-10-10 13:22:59 -0400 | [diff] [blame] | 61 | function and adds an header row on top of it. |
Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 62 | } |
Hao Zhu | 78e6122 | 2017-05-24 20:53:35 -0400 | [diff] [blame] | 63 | \examples{ |
| 64 | x <- knitr::kable(head(mtcars), "html") |
| 65 | # Add a row of header with 3 columns on the top of the table. The column |
| 66 | # span for the 2nd and 3rd one are 5 & 6. |
| 67 | add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6)) |
| 68 | |
| 69 | } |