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 | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 7 | collapse_rows(kable_input, columns = NULL) |
| 8 | } |
| 9 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 10 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 11 | |
| 12 | \item{columns}{Numeric column positions where rows need to be collapsed.} |
Hao Zhu | 2a87e8e | 2017-06-14 15:49:33 -0400 | [diff] [blame] | 13 | } |
| 14 | \description{ |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 15 | Collapse same values in columns into multirow cells. This |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 16 | 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] | 17 | it analyzes existing columns, finds out rows that can be grouped together, |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 18 | and make them multirow cells. Note that if you want to use \code{column_spec} to |
| 19 | 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] | 20 | } |
Hao Zhu | 5a7689e | 2017-06-26 15:37:24 -1000 | [diff] [blame] | 21 | \examples{ |
| 22 | dt <- data.frame(a = c(1, 1, 2, 2), b = c("a", "a", "a", "b")) |
| 23 | x <- knitr::kable(dt, "html") |
| 24 | collapse_rows(x) |
| 25 | |
| 26 | } |