blob: a05622507cc9f4725b4348bef68bb1a7cfef4116 [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 Zhuac7e70f2017-08-02 00:18:36 -04007add_header_above(kable_input, header = NULL, bold = FALSE, italic = FALSE,
Hao Zhu68b5bbf2018-03-26 11:30:34 -04008 monospace = FALSE, escape = TRUE, line = TRUE)
Hao Zhuc1f38412017-02-23 12:13:48 -05009}
Hao Zhuf7994dd2017-02-27 16:58:42 -050010\arguments{
Hao Zhu76281fe2017-07-03 19:33:09 -040011\item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified}
Hao Zhuf7994dd2017-02-27 16:58:42 -050012
Hao Zhu76281fe2017-07-03 19:33:09 -040013\item{header}{A (named) character vector with \code{colspan} as values. For
14example, \code{c(" " = 1, "title" = 2)} can be used to create a new header row
Hao Zhuf7994dd2017-02-27 16:58:42 -050015for a 3-column table with "title" spanning across column 2 and 3. For
Hao Zhu76281fe2017-07-03 19:33:09 -040016convenience, when \code{colspan} equals to 1, users can drop the \code{= 1} part.
17As a result, \code{c(" ", "title" = 2)} is the same as \code{c(" " = 1, "title" = 2)}.}
Hao Zhu32f43f72017-06-20 18:24:54 -040018
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 Zhuac7e70f2017-08-02 00:18:36 -040022
23\item{monospace}{A T/F value to control whether the text of the selected column
24need to be monospaced (verbatim)}
25
26\item{escape}{A T/F value showing whether special characters should be
27escaped.}
Hao Zhu68b5bbf2018-03-26 11:30:34 -040028
29\item{line}{A T/F value to control whether a line will appear underneath the
30header}
Hao Zhuf7994dd2017-02-27 16:58:42 -050031}
Hao Zhuc1f38412017-02-23 12:13:48 -050032\description{
Hao Zhuf7994dd2017-02-27 16:58:42 -050033Tables with multiple rows of header rows are extremely useful
Hao Zhu76281fe2017-07-03 19:33:09 -040034to demonstrate grouped data. This function takes the output of a \code{kable()}
Hao Zhue7c8f702017-10-10 13:22:59 -040035function and adds an header row on top of it.
Hao Zhuc1f38412017-02-23 12:13:48 -050036}
Hao Zhu78e61222017-05-24 20:53:35 -040037\examples{
38x <- knitr::kable(head(mtcars), "html")
39# Add a row of header with 3 columns on the top of the table. The column
40# span for the 2nd and 3rd one are 5 & 6.
41add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6))
42
43}