blob: 75f49fcdebc5b37b10f147935728804754d83017 [file] [log] [blame]
Hao Zhuc1f38412017-02-23 12:13:48 -05001% 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 Zhuf7994dd2017-02-27 16:58:42 -05005\title{Add a header row on top of current header}
Hao Zhuc1f38412017-02-23 12:13:48 -05006\usage{
Hao Zhu76f0eb62018-09-15 12:38:33 -04007add_header_above(kable_input, header = NULL, bold = FALSE,
8 italic = FALSE, monospace = FALSE, underline = FALSE,
9 strikeout = FALSE, align = "c", color = NULL, background = NULL,
Hao Zhu6d68f7c2018-09-15 12:44:15 -040010 font_size = NULL, angle = NULL, escape = TRUE, line = TRUE,
11 extra_css = NULL)
Hao Zhuc1f38412017-02-23 12:13:48 -050012}
Hao Zhuf7994dd2017-02-27 16:58:42 -050013\arguments{
Hao Zhu76281fe2017-07-03 19:33:09 -040014\item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified}
Hao Zhuf7994dd2017-02-27 16:58:42 -050015
Hao Zhu76281fe2017-07-03 19:33:09 -040016\item{header}{A (named) character vector with \code{colspan} as values. For
17example, \code{c(" " = 1, "title" = 2)} can be used to create a new header row
Hao Zhuf7994dd2017-02-27 16:58:42 -050018for a 3-column table with "title" spanning across column 2 and 3. For
Hao Zhu76281fe2017-07-03 19:33:09 -040019convenience, when \code{colspan} equals to 1, users can drop the \code{= 1} part.
20As a result, \code{c(" ", "title" = 2)} is the same as \code{c(" " = 1, "title" = 2)}.}
Hao Zhu32f43f72017-06-20 18:24:54 -040021
22\item{bold}{A T/F value to control whether the text should be bolded.}
23
24\item{italic}{A T/F value to control whether the text should to be emphasized.}
Hao Zhuac7e70f2017-08-02 00:18:36 -040025
26\item{monospace}{A T/F value to control whether the text of the selected column
27need to be monospaced (verbatim)}
28
Hao Zhu76f0eb62018-09-15 12:38:33 -040029\item{underline}{A T/F value to control whether the text of the selected row
30need to be underlined}
31
32\item{strikeout}{A T/F value to control whether the text of the selected row
33need to be stricked out.}
34
Hao Zhu3465b502018-04-02 22:41:46 -040035\item{align}{A character string for cell alignment. For HTML, possible values could
36be \code{l}, \code{c}, \code{r} plus \code{left}, \code{center}, \code{right}, \code{justify}, \code{initial} and \code{inherit}
37while for LaTeX, you can only choose from \code{l}, \code{c} & \code{r}.}
38
Hao Zhu76f0eb62018-09-15 12:38:33 -040039\item{color}{A character string/vector for text color. Here please pay
40attention to the differences in color codes between HTML and LaTeX.}
41
42\item{background}{A character string/vector for background color. Here please
43pay attention to the differences in color codes between HTML and LaTeX. Also
44note that in HTML, background defined in cell_spec won't cover the whole
45cell.}
46
47\item{font_size}{A numeric input/vector for font size. For HTML, you can also use
48options including \code{xx-small}, \code{x-small}, \code{small}, \code{medium}, \code{large},
49\code{x-large}, \code{xx-large}, \code{smaller}, \code{larger}, \code{initial} and \code{inherit}.}
50
51\item{angle}{0-360, degree that the text will rotate.}
52
Hao Zhuac7e70f2017-08-02 00:18:36 -040053\item{escape}{A T/F value showing whether special characters should be
54escaped.}
Hao Zhu68b5bbf2018-03-26 11:30:34 -040055
56\item{line}{A T/F value to control whether a line will appear underneath the
57header}
Hao Zhu6d68f7c2018-09-15 12:44:15 -040058
59\item{extra_css}{An HTML only option. CSS defined here will be send to the
60td cell.}
Hao Zhuf7994dd2017-02-27 16:58:42 -050061}
Hao Zhuc1f38412017-02-23 12:13:48 -050062\description{
Hao Zhuf7994dd2017-02-27 16:58:42 -050063Tables with multiple rows of header rows are extremely useful
Hao Zhu76281fe2017-07-03 19:33:09 -040064to demonstrate grouped data. This function takes the output of a \code{kable()}
Hao Zhue7c8f702017-10-10 13:22:59 -040065function and adds an header row on top of it.
Hao Zhuc1f38412017-02-23 12:13:48 -050066}
Hao Zhu78e61222017-05-24 20:53:35 -040067\examples{
68x <- knitr::kable(head(mtcars), "html")
69# Add a row of header with 3 columns on the top of the table. The column
70# span for the 2nd and 3rd one are 5 & 6.
71add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6))
72
73}