blob: e1078a3925e4697f92014421b82ff7077451a8bd [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{
Hao Zhu76281fe2017-07-03 19:33:09 -040010\item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified}
Hao Zhu8a160b12017-06-26 13:41:35 -100011
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
Hao Zhu76281fe2017-07-03 19:33:09 -040016feature does similar things with \code{group_rows}. However, unlike \code{group_rows},
Hao Zhu8a160b12017-06-26 13:41:35 -100017it analyzes existing columns, finds out rows that can be grouped together,
Hao Zhu76281fe2017-07-03 19:33:09 -040018and make them multirow cells. Note that if you want to use \code{column_spec} to
19specify column styles, you should use \code{column_spec} before \code{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}