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", |
Hao Zhu | 248bbef | 2018-04-02 18:25:14 -0400 | [diff] [blame] | 8 | "none", "custom"), row_group_label_position = c("identity", "stack"), |
| 9 | custom_latex_hline = NULL, row_group_label_fonts = NULL, |
| 10 | headers_to_remove = NULL) |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 11 | } |
| 12 | \arguments{ |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 13 | \item{kable_input}{Output of \code{knitr::kable()} with \code{format} specified} |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 14 | |
| 15 | \item{columns}{Numeric column positions where rows need to be collapsed.} |
Hao Zhu | 53454f0 | 2018-01-14 16:29:10 -0500 | [diff] [blame] | 16 | |
| 17 | \item{latex_hline}{Option controlling the behavior of adding hlines to table. |
Hao Zhu | 248bbef | 2018-04-02 18:25:14 -0400 | [diff] [blame] | 18 | Choose from \code{full}, \code{major}, \code{none}, \code{custom}.} |
| 19 | |
| 20 | \item{row_group_label_position}{Option controlling positions of row group |
| 21 | labels. Choose from \code{identity}, \code{stack}.} |
| 22 | |
| 23 | \item{custom_latex_hline}{Numeric column positions whose collapsed rows will |
| 24 | be separated by hlines.} |
| 25 | |
| 26 | \item{row_group_label_fonts}{A list of arguments that can be supplied to |
| 27 | group_rows function to format the row group label when |
| 28 | \code{row_group_label_position} is \code{stack}} |
| 29 | |
| 30 | \item{headers_to_remove}{Numeric column positions where headers should be |
| 31 | removed when they are stacked.} |
Hao Zhu | 2a87e8e | 2017-06-14 15:49:33 -0400 | [diff] [blame] | 32 | } |
| 33 | \description{ |
Hao Zhu | 8a160b1 | 2017-06-26 13:41:35 -1000 | [diff] [blame] | 34 | Collapse same values in columns into multirow cells. This |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 35 | 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] | 36 | it analyzes existing columns, finds out rows that can be grouped together, |
Hao Zhu | 76281fe | 2017-07-03 19:33:09 -0400 | [diff] [blame] | 37 | and make them multirow cells. Note that if you want to use \code{column_spec} to |
| 38 | 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] | 39 | } |
Hao Zhu | 5a7689e | 2017-06-26 15:37:24 -1000 | [diff] [blame] | 40 | \examples{ |
| 41 | dt <- data.frame(a = c(1, 1, 2, 2), b = c("a", "a", "a", "b")) |
| 42 | x <- knitr::kable(dt, "html") |
| 43 | collapse_rows(x) |
| 44 | |
| 45 | } |