Hao Zhu | 2a87e8e | 2017-06-14 15:49:33 -0400 | [diff] [blame] | 1 | % 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 Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 5 | \title{Collapse repeated rows to multirow cell} |
Hao Zhu | 2a87e8e | 2017-06-14 15:49:33 -0400 | [diff] [blame] | 6 | \usage{ |
Hao Zhu | 53454f0 | 2018-01-14 16:29:10 -0500 | [diff] [blame] | 7 | collapse_rows(kable_input, columns = NULL, latex_hline = c("full", "major", |
| 8 | "none")) |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 9 | } |
| 10 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 11 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 12 | |
| 13 | \item{columns}{Numeric column positions where rows need to be collapsed.} |
Hao Zhu | 53454f0 | 2018-01-14 16:29:10 -0500 | [diff] [blame] | 14 | |
| 15 | \item{latex_hline}{Option controlling the behavior of adding hlines to table. |
| 16 | Choose from \code{full}, \code{major}, \code{none}.} |
Hao Zhu | 2a87e8e | 2017-06-14 15:49:33 -0400 | [diff] [blame] | 17 | } |
| 18 | \description{ |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 19 | Collapse same values in columns into multirow cells. This |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 20 | feature does similar things with \code{group_rows}. However, unlike \code{group_rows}, |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 21 | it analyzes existing columns, finds out rows that can be grouped together, |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 22 | and make them multirow cells. Note that if you want to use \code{column_spec} to |
| 23 | specify column styles, you should use \code{column_spec} before \code{collapse_rows}. |
Hao Zhu | 2a87e8e | 2017-06-14 15:49:33 -0400 | [diff] [blame] | 24 | } |
Hao Zhu | 5a7689e | 2017-06-26 15:37:24 -1000 | [diff] [blame] | 25 | \examples{ |
| 26 | dt <- data.frame(a = c(1, 1, 2, 2), b = c("a", "a", "a", "b")) |
| 27 | x <- knitr::kable(dt, "html") |
| 28 | collapse_rows(x) |
| 29 | |
| 30 | } |