blob: 677214a99203fdb5f618f882d87c398e4c8b8fea [file] [log] [blame]
Hao Zhu2a87e8e2017-06-14 15:49:33 -04001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/collapse_rows.R
3\name{collapse_rows}
4\alias{collapse_rows}
Hao Zhu8a160b12017-06-26 13:41:35 -10005\title{Collapse repeated rows to multirow cell}
Hao Zhu2a87e8e2017-06-14 15:49:33 -04006\usage{
Hao Zhu53454f02018-01-14 16:29:10 -05007collapse_rows(kable_input, columns = NULL, latex_hline = c("full", "major",
8 "none"))
Hao Zhu8a160b12017-06-26 13:41:35 -10009}
10\arguments{
Hao Zhu76281fe2017-07-03 19:33:09 -040011\item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified}
Hao Zhu8a160b12017-06-26 13:41:35 -100012
13\item{columns}{Numeric column positions where rows need to be collapsed.}
Hao Zhu53454f02018-01-14 16:29:10 -050014
15\item{latex_hline}{Option controlling the behavior of adding hlines to table.
16Choose from \code{full}, \code{major}, \code{none}.}
Hao Zhu2a87e8e2017-06-14 15:49:33 -040017}
18\description{
Hao Zhu8a160b12017-06-26 13:41:35 -100019Collapse same values in columns into multirow cells. This
Hao Zhu76281fe2017-07-03 19:33:09 -040020feature does similar things with \code{group_rows}. However, unlike \code{group_rows},
Hao Zhu8a160b12017-06-26 13:41:35 -100021it analyzes existing columns, finds out rows that can be grouped together,
Hao Zhu76281fe2017-07-03 19:33:09 -040022and make them multirow cells. Note that if you want to use \code{column_spec} to
23specify column styles, you should use \code{column_spec} before \code{collapse_rows}.
Hao Zhu2a87e8e2017-06-14 15:49:33 -040024}
Hao Zhu5a7689e2017-06-26 15:37:24 -100025\examples{
26dt <- data.frame(a = c(1, 1, 2, 2), b = c("a", "a", "a", "b"))
27x <- knitr::kable(dt, "html")
28collapse_rows(x)
29
30}