blob: 4752d8048f04049de7385f60c3acba24342d3e80 [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 Zhuec169362018-05-21 01:05:29 -04007collapse_rows(kable_input, columns = NULL, valign = c("middle", "top",
Hao Zhube853f72018-05-20 18:52:26 -04008 "bottom"), latex_hline = c("full", "major", "none", "custom"),
9 row_group_label_position = c("identity", "stack"),
Hao Zhu248bbef2018-04-02 18:25:14 -040010 custom_latex_hline = NULL, row_group_label_fonts = NULL,
11 headers_to_remove = NULL)
Hao Zhu8a160b12017-06-26 13:41:35 -100012}
13\arguments{
Hao Zhu76281fe2017-07-03 19:33:09 -040014\item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified}
Hao Zhu8a160b12017-06-26 13:41:35 -100015
Jakob Richteraebd8292018-10-31 16:27:29 +010016\item{columns}{A numeric value or vector indicating in which column(s) rows
17need to be collapsed.}
Hao Zhu53454f02018-01-14 16:29:10 -050018
Hao Zhuec169362018-05-21 01:05:29 -040019\item{valign}{Select from "top", "middle"(default), "bottom". The reason why
20"top" is not default is that the multirow package on CRAN win-builder is
21not up to date.}
Hao Zhube853f72018-05-20 18:52:26 -040022
Hao Zhu53454f02018-01-14 16:29:10 -050023\item{latex_hline}{Option controlling the behavior of adding hlines to table.
Hao Zhu248bbef2018-04-02 18:25:14 -040024Choose from \code{full}, \code{major}, \code{none}, \code{custom}.}
25
26\item{row_group_label_position}{Option controlling positions of row group
27labels. Choose from \code{identity}, \code{stack}.}
28
29\item{custom_latex_hline}{Numeric column positions whose collapsed rows will
30be separated by hlines.}
31
32\item{row_group_label_fonts}{A list of arguments that can be supplied to
33group_rows function to format the row group label when
34\code{row_group_label_position} is \code{stack}}
35
36\item{headers_to_remove}{Numeric column positions where headers should be
37removed when they are stacked.}
Hao Zhu2a87e8e2017-06-14 15:49:33 -040038}
39\description{
Hao Zhu8a160b12017-06-26 13:41:35 -100040Collapse same values in columns into multirow cells. This
Hao Zhu76281fe2017-07-03 19:33:09 -040041feature does similar things with \code{group_rows}. However, unlike \code{group_rows},
Hao Zhu8a160b12017-06-26 13:41:35 -100042it analyzes existing columns, finds out rows that can be grouped together,
Hao Zhu76281fe2017-07-03 19:33:09 -040043and make them multirow cells. Note that if you want to use \code{column_spec} to
44specify column styles, you should use \code{column_spec} before \code{collapse_rows}.
Hao Zhu2a87e8e2017-06-14 15:49:33 -040045}
Hao Zhu5a7689e2017-06-26 15:37:24 -100046\examples{
47dt <- data.frame(a = c(1, 1, 2, 2), b = c("a", "a", "a", "b"))
48x <- knitr::kable(dt, "html")
49collapse_rows(x)
50
51}