blob: 49deb7f1070b4883b185057aece4d349123c3dc9 [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 Zhu8a160b12017-06-26 13:41:35 -10007collapse_rows(kable_input, columns = NULL)
8}
9\arguments{
10\item{kable_input}{Output of `knitr::kable()` with `format` specified}
11
12\item{columns}{Numeric column positions where rows need to be collapsed.}
Hao Zhu2a87e8e2017-06-14 15:49:33 -040013}
14\description{
Hao Zhu8a160b12017-06-26 13:41:35 -100015Collapse same values in columns into multirow cells. This
16feature does similar things with `group_rows`. However, unlike `group_rows`,
17it analyzes existing columns, finds out rows that can be grouped together,
18and make them multirow cells. Note that if you want to use `column_spec` to
19specify column styles, you should use `column_spec` before `collapse_rows`.
Hao Zhu2a87e8e2017-06-14 15:49:33 -040020}
Hao Zhu5a7689e2017-06-26 15:37:24 -100021\examples{
22dt <- data.frame(a = c(1, 1, 2, 2), b = c("a", "a", "a", "b"))
23x <- knitr::kable(dt, "html")
24collapse_rows(x)
25
26}