blob: 09b976d9f6ffb2ac96c9597642461f0d3e0b284c [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{
7add_header_above(kable_input, header = NULL)
8}
Hao Zhuf7994dd2017-02-27 16:58:42 -05009\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
13example, `c(" " = 1, "title" = 2)` can be used to create a new header row
14for a 3-column table with "title" spanning across column 2 and 3. For
15convenience, when `colspan` equals to 1, users can drop the ` = 1` part.
16As a result, `c(" ", "title" = 2)` is the same as `c(" " = 1, "title" = 2)`.}
17}
Hao Zhuc1f38412017-02-23 12:13:48 -050018\description{
Hao Zhuf7994dd2017-02-27 16:58:42 -050019Tables with multiple rows of header rows are extremely useful
20to demonstrate grouped data. This function takes the output of a `kable()`
21function and adds an header row on top of it. This function can work with
22both `HTML` and `LaTeX` outputs
Hao Zhuc1f38412017-02-23 12:13:48 -050023}
Hao Zhu78e61222017-05-24 20:53:35 -040024\examples{
25x <- knitr::kable(head(mtcars), "html")
26# Add a row of header with 3 columns on the top of the table. The column
27# span for the 2nd and 3rd one are 5 & 6.
28add_header_above(x, c(" ", "Group 1" = 5, "Group 2" = 6))
29
30}