blob: a32c56e50bd6b658427c53bd6bbc6e1b4b1c625a [file] [log] [blame]
Hao Zhu3166f062017-06-26 07:51:46 -10001#' Collapse repeated rows to multirow cell
Hao Zhu2a87e8e2017-06-14 15:49:33 -04002#'
Hao Zhu8a160b12017-06-26 13:41:35 -10003#' @description Collapse same values in columns into multirow cells. This
4#' feature does similar things with `group_rows`. However, unlike `group_rows`,
5#' it analyzes existing columns, finds out rows that can be grouped together,
6#' and make them multirow cells. Note that if you want to use `column_spec` to
7#' specify column styles, you should use `column_spec` before `collapse_rows`.
8#'
9#' @param kable_input Output of `knitr::kable()` with `format` specified
Hao Zhu5e2528e2020-08-03 09:16:34 -040010#' @param columns A numeric value or vector indicating in which column(s) rows
Jakob Richteraebd8292018-10-31 16:27:29 +010011#' need to be collapsed.
Hao Zhuec169362018-05-21 01:05:29 -040012#' @param valign Select from "top", "middle"(default), "bottom". The reason why
13#' "top" is not default is that the multirow package on CRAN win-builder is
14#' not up to date.
Hao Zhu12b0ade2018-01-13 16:19:58 -050015#' @param latex_hline Option controlling the behavior of adding hlines to table.
Hao Zhud0f7c8a2020-08-20 01:17:23 -040016#' Choose from `full`, `major`, `none`, `custom` and `linespace`.
georgeguieaeb0cd2018-03-30 17:39:46 -050017#' @param custom_latex_hline Numeric column positions whose collapsed rows will
18#' be separated by hlines.
19#' @param row_group_label_position Option controlling positions of row group
20#' labels. Choose from `identity`, `stack`.
21#' @param row_group_label_fonts A list of arguments that can be supplied to
22#' group_rows function to format the row group label when
23#' `row_group_label_position` is `stack`
24#' @param headers_to_remove Numeric column positions where headers should be
25#' removed when they are stacked.
Hao Zhuc9858942020-08-11 21:41:09 -040026#' @param target If multiple columns are selected to do collapsing and a target
27#' column is specified, this target column will be used to collapse other
28#' columns based on the groups of this target column.
29#' @param col_names T/F. A LaTeX specific option. If you set `col.names` be
30#' `NULL` in your `kable` call, you need to set this option false to let
31#' everything work properly.
Hao Zhu71b30f22020-08-12 22:47:13 -040032#' @param longtable_clean_cut T/F with default T. Multirow cell sometimes are
33#' displayed incorrectly around pagebreak. This option forces groups to cut
34#' before the end of a page. If you have a group that is longer than 1 page,
35#' you need to turn off this option.
Hao Zhu8a160b12017-06-26 13:41:35 -100036#'
Hao Zhu9399dcc2020-08-26 17:27:38 -040037#' @examples
38#' \dontrun{
39#' dt <- data.frame(a = c(1, 1, 2, 2), b = c("a", "a", "a", "b"))
Hao Zhu5a7689e2017-06-26 15:37:24 -100040#' x <- knitr::kable(dt, "html")
41#' collapse_rows(x)
Hao Zhu9399dcc2020-08-26 17:27:38 -040042#' }
Hao Zhu5a7689e2017-06-26 15:37:24 -100043#'
Hao Zhuf4b35292017-06-25 22:38:37 -100044#' @export
Hao Zhu12b0ade2018-01-13 16:19:58 -050045collapse_rows <- function(kable_input, columns = NULL,
Hao Zhuec169362018-05-21 01:05:29 -040046 valign = c("middle", "top", "bottom"),
Hao Zhud0f7c8a2020-08-20 01:17:23 -040047 latex_hline = c("full", "major", "none", "custom",
48 "linespace"),
georgeguieaeb0cd2018-03-30 17:39:46 -050049 row_group_label_position = c('identity', 'stack'),
50 custom_latex_hline = NULL,
51 row_group_label_fonts = NULL,
Hao Zhu5e2528e2020-08-03 09:16:34 -040052 headers_to_remove = NULL,
Hao Zhuc9858942020-08-11 21:41:09 -040053 target = NULL,
Hao Zhu71b30f22020-08-12 22:47:13 -040054 col_names = TRUE,
55 longtable_clean_cut = TRUE) {
Hao Zhu2a87e8e2017-06-14 15:49:33 -040056 kable_format <- attr(kable_input, "format")
57 if (!kable_format %in% c("html", "latex")) {
Hao Zhu401ebd82018-01-14 17:10:20 -050058 warning("Please specify format in kable. kableExtra can customize either ",
59 "HTML or LaTeX outputs. See https://haozhu233.github.io/kableExtra/ ",
60 "for details.")
Hao Zhu2a87e8e2017-06-14 15:49:33 -040061 return(kable_input)
62 }
Hao Zhu33b865f2020-08-18 02:10:43 -040063 valign <- match.arg(valign)
Hao Zhu5e2528e2020-08-03 09:16:34 -040064 if (!is.null(target)) {
65 if (length(target) > 1 && is.integer(target)) {
66 stop("target can only be a length 1 integer")
67 }
68 }
Hao Zhu2a87e8e2017-06-14 15:49:33 -040069 if (kable_format == "html") {
Hao Zhu5e2528e2020-08-03 09:16:34 -040070 return(collapse_rows_html(kable_input, columns, valign, target))
Hao Zhu2a87e8e2017-06-14 15:49:33 -040071 }
72 if (kable_format == "latex") {
Hao Zhu33b865f2020-08-18 02:10:43 -040073 latex_hline <- match.arg(latex_hline)
georgeguieaeb0cd2018-03-30 17:39:46 -050074 row_group_label_position <- match.arg(row_group_label_position,
75 c('identity', 'stack'))
Hao Zhu5dd3e282018-05-20 18:39:48 -040076 return(collapse_rows_latex(kable_input, columns, latex_hline, valign,
georgeguieaeb0cd2018-03-30 17:39:46 -050077 row_group_label_position, row_group_label_fonts, custom_latex_hline,
Hao Zhu71b30f22020-08-12 22:47:13 -040078 headers_to_remove, target, col_names, longtable_clean_cut))
Hao Zhu2a87e8e2017-06-14 15:49:33 -040079 }
80}
81
Hao Zhu5e2528e2020-08-03 09:16:34 -040082collapse_rows_html <- function(kable_input, columns, valign, target) {
Hao Zhu2a87e8e2017-06-14 15:49:33 -040083 kable_attrs <- attributes(kable_input)
Hao Zhu5e2528e2020-08-03 09:16:34 -040084 kable_xml <- kable_as_xml(kable_input)
Hao Zhu2a87e8e2017-06-14 15:49:33 -040085 kable_tbody <- xml_tpart(kable_xml, "tbody")
86
87 kable_dt <- rvest::html_table(xml2::read_html(as.character(kable_input)))[[1]]
Hao Zhuf4b35292017-06-25 22:38:37 -100088 if (is.null(columns)) {
89 columns <- seq(1, ncol(kable_dt))
90 }
Hao Zhu5e2528e2020-08-03 09:16:34 -040091 if (!is.null(target)) {
92 if (!target %in% columns) {
93 stop("target has to be within the range of columns")
94 }
95 }
Hao Zhu23456762018-03-26 12:30:10 -040096 if (!is.null(kable_attrs$header_above)) {
97 kable_dt_col_names <- unlist(kable_dt[kable_attrs$header_above, ])
98 kable_dt <- kable_dt[-(1:kable_attrs$header_above),]
99 names(kable_dt) <- kable_dt_col_names
100 }
Hao Zhu5e2528e2020-08-03 09:16:34 -0400101 collapse_matrix <- collapse_row_matrix(kable_dt, columns, target = target)
Hao Zhu2a87e8e2017-06-14 15:49:33 -0400102
103 for (i in 1:nrow(collapse_matrix)) {
104 matrix_row <- collapse_matrix[i, ]
Hao Zhu38cdcdb2017-06-27 09:08:30 -1000105 names(matrix_row) <- names(collapse_matrix)
Hao Zhu3166f062017-06-26 07:51:46 -1000106 target_row <- xml_child(kable_tbody, i)
107 row_node_rm_count <- 0
108 for (j in 1:length(matrix_row)) {
109 collapsing_col <- as.numeric(sub("x", "", names(matrix_row)[j])) -
110 row_node_rm_count
111 target_cell <- xml_child(target_row, collapsing_col)
112 if (matrix_row[j] == 0) {
113 xml_remove(target_cell)
114 row_node_rm_count <- row_node_rm_count + 1
115 } else if (matrix_row[j] != 1) {
116 xml_attr(target_cell, "rowspan") <- matrix_row[j]
117 xml_attr(target_cell, "style") <- paste0(
118 xml_attr(target_cell, "style"),
Hao Zhu5dd3e282018-05-20 18:39:48 -0400119 "vertical-align: ", valign, " !important;")
Hao Zhu2a87e8e2017-06-14 15:49:33 -0400120 }
121 }
122 }
123
Hao Zhuf2dfd142017-07-24 14:43:28 -0400124 out <- as_kable_xml(kable_xml)
Hao Zhufdff6f42020-08-09 14:38:10 -0400125 kable_attrs$collapse_matrix <- collapse_matrix
Hao Zhu2a87e8e2017-06-14 15:49:33 -0400126 attributes(out) <- kable_attrs
Hao Zhuf2100832018-01-11 16:20:29 -0500127 if (!"kableExtra" %in% class(out)) class(out) <- c("kableExtra", class(out))
Hao Zhu2a87e8e2017-06-14 15:49:33 -0400128 return(out)
129}
130
Hao Zhu5e2528e2020-08-03 09:16:34 -0400131split_factor <- function(x) {
132 group_idx <- seq(1, length(x))
133 return(factor(unlist(lapply(group_idx, function(i) {rep(i, x[i])}))))
134}
135
136collapse_row_matrix <- function(kable_dt, columns, html = T, target = NULL) {
Hao Zhuf4b35292017-06-25 22:38:37 -1000137 if (html) {
138 column_block <- function(x) c(x, rep(0, x - 1))
139 } else {
140 column_block <- function(x) c(rep(0, x - 1), x)
141 }
142 mapping_matrix <- list()
Hao Zhu5e2528e2020-08-03 09:16:34 -0400143 if (is.null(target)) {
144 for (i in columns) {
145 mapping_matrix[[paste0("x", i)]] <- unlist(lapply(
146 rle(kable_dt[, i])$lengths, column_block))
147 }
148 } else {
149 target_group = split_factor(rle(kable_dt[, target])$lengths)
150 for (i in columns) {
151 column_split = split(kable_dt[, i], target_group)
152 mapping_matrix[[paste0("x", i)]] <- unlist(lapply(
153 column_split, function(sp) {
154 lapply(rle(sp)$length, column_block)
155 }))
156 }
Hao Zhuf4b35292017-06-25 22:38:37 -1000157 }
Hao Zhu5e2528e2020-08-03 09:16:34 -0400158
Hao Zhuf4b35292017-06-25 22:38:37 -1000159 mapping_matrix <- data.frame(mapping_matrix)
160 return(mapping_matrix)
161}
162
Hao Zhu5dd3e282018-05-20 18:39:48 -0400163collapse_rows_latex <- function(kable_input, columns, latex_hline, valign,
georgeguieaeb0cd2018-03-30 17:39:46 -0500164 row_group_label_position, row_group_label_fonts,
Hao Zhuc9858942020-08-11 21:41:09 -0400165 custom_latex_hline, headers_to_remove, target,
Hao Zhu71b30f22020-08-12 22:47:13 -0400166 col_names, longtable_clean_cut) {
Hao Zhuf4b35292017-06-25 22:38:37 -1000167 table_info <- magic_mirror(kable_input)
Hao Zhuc33b1f42020-10-05 23:16:57 -0400168 if (table_info$nrow <= 2) return(kable_input)
Hao Zhu3fc0e882018-04-03 16:06:41 -0400169 out <- solve_enc(kable_input)
Hao Zhu876bcb02020-08-12 23:02:51 -0400170 out <- gsub("\\\\addlinespace\n", "", out)
Hao Zhu064990d2017-10-17 18:08:42 -0400171
Hao Zhu5dd3e282018-05-20 18:39:48 -0400172 valign <- switch(
173 valign,
174 top = "\\[t\\]",
175 middle = "",
176 bottom = "\\[b\\]"
177 )
178
Hao Zhuf4b35292017-06-25 22:38:37 -1000179 if (is.null(columns)) {
180 columns <- seq(1, table_info$ncol)
181 }
Hao Zhu064990d2017-10-17 18:08:42 -0400182
Hao Zhuf4b35292017-06-25 22:38:37 -1000183 contents <- table_info$contents
Hao Zhuc9858942020-08-11 21:41:09 -0400184 kable_dt <- kable_dt_latex(contents, col_names)
georgeguieaeb0cd2018-03-30 17:39:46 -0500185
Hao Zhuaa424412020-08-03 09:21:46 -0400186 collapse_matrix_rev <- collapse_row_matrix(kable_dt, columns, html = TRUE,
187 target)
188 collapse_matrix <- collapse_row_matrix(kable_dt, columns, html = FALSE,
189 target)
Hao Zhuf4b35292017-06-25 22:38:37 -1000190
191 new_kable_dt <- kable_dt
Jakob Richteraebd8292018-10-31 16:27:29 +0100192 for (j in seq_along(columns)) {
Hao Zhuf4b35292017-06-25 22:38:37 -1000193 column_align <- table_info$align_vector_origin[columns[j]]
194 column_width <- ifelse(
195 is.null(table_info$column_width[[paste0("column_", columns[j])]]),
Hao Zhu4e34cd82020-08-19 01:54:23 -0400196 "\\*", table_info$column_width[paste0("column_", columns[j])])
Hao Zhuf4b35292017-06-25 22:38:37 -1000197 for (i in seq(1:nrow(collapse_matrix))) {
georgeguieaeb0cd2018-03-30 17:39:46 -0500198 if(row_group_label_position == 'stack'){
Jakob Richteraebd8292018-10-31 16:27:29 +0100199 if(columns[j] < ncol(collapse_matrix) || collapse_matrix_rev[i, j] == 0){
200 new_kable_dt[i, columns[j]] <- ''
georgeguieaeb0cd2018-03-30 17:39:46 -0500201 }
202 } else {
Jakob Richteraebd8292018-10-31 16:27:29 +0100203 new_kable_dt[i, columns[j]] <- collapse_new_dt_item(
204 kable_dt[i, columns[j]], collapse_matrix[i, j], column_width,
Hao Zhu5dd3e282018-05-20 18:39:48 -0400205 align = column_align, valign = valign
georgeguieaeb0cd2018-03-30 17:39:46 -0500206 )
207 }
Hao Zhuf4b35292017-06-25 22:38:37 -1000208 }
209 }
Hao Zhu654c91f2017-07-03 14:03:34 -0400210
211 midrule_matrix <- collapse_row_matrix(kable_dt, seq(1, table_info$ncol),
Hao Zhuaa424412020-08-03 09:21:46 -0400212 html = FALSE, target)
Hao Zhu654c91f2017-07-03 14:03:34 -0400213 midrule_matrix[setdiff(seq(1, table_info$ncol), columns)] <- 1
214
215 ex_bottom <- length(contents) - 1
216 contents[2:ex_bottom] <- paste0(contents[2:ex_bottom], "\\\\\\\\")
217 if (!table_info$booktabs) {
218 contents[2:ex_bottom] <- paste0(contents[2:ex_bottom], "\n\\\\hline")
219 }
Hao Zhu01b15b82018-01-12 17:48:21 -0500220
221 new_contents <- c()
georgeguieaeb0cd2018-03-30 17:39:46 -0500222 if(row_group_label_position == 'stack'){
223 if(is.null(headers_to_remove)) headers_to_remove <- head(columns, -1)
224 table_info$colnames[headers_to_remove] <- ''
225 new_header <- paste(table_info$colnames, collapse = ' & ')
226 out <- sub(contents[1], new_header, out)
227 table_info$contents[1] <- new_header
228 }
229 if(latex_hline == 'custom' & is.null(custom_latex_hline)){
230 if(row_group_label_position == 'stack'){
231 custom_latex_hline = 1:2
232 } else {
233 custom_latex_hline = 1
234 }
235 }
Hao Zhud0f7c8a2020-08-20 01:17:23 -0400236
237 if (table_info$tabular == "longtable" & longtable_clean_cut) {
238 if (max(collapse_matrix) > 50) {
239 warning("It seems that you have a group larger than 50 rows and span ",
240 "over a page. You probably want to set longtable_clean_cut to ",
241 "be FALSE.")
242 }
243 pagebreak_hint <- "\\\\pagebreak[0]"
244 nopagebreak <- "\\\\nopagebreak"
245 # out <- gsub("\\\\\\\\($|\n)", "\\\\\\\\\\\\nopagebreak\\1", out)
246 # out <- gsub("(\\\\cmidrule[{][^}]*[}])", "\\1\\\\pagebreak[0]", out)
247 } else {
248 pagebreak_hint <- ""
249 nopagebreak <- ""
250 }
251
Hao Zhuf4b35292017-06-25 22:38:37 -1000252 for (i in seq(1:nrow(collapse_matrix))) {
253 new_contents[i] <- paste0(new_kable_dt[i, ], collapse = " & ")
Hao Zhu12b0ade2018-01-13 16:19:58 -0500254 table_info$contents[i + 1] <- new_contents[i]
Hao Zhu654c91f2017-07-03 14:03:34 -0400255 if (i != nrow(collapse_matrix)) {
Hao Zhu12b0ade2018-01-13 16:19:58 -0500256 row_midrule <- switch(
257 latex_hline,
258 "none" = "",
Hao Zhud0f7c8a2020-08-20 01:17:23 -0400259 "full" = paste0(
Hao Zhu71b30f22020-08-12 22:47:13 -0400260 midline_groups(which(as.numeric(midrule_matrix[i, ]) > 0),
261 table_info$booktabs),
Hao Zhud0f7c8a2020-08-20 01:17:23 -0400262 ifelse(
263 sum(as.numeric(midrule_matrix[i, ]) > 0) == ncol(midrule_matrix),
264 pagebreak_hint, nopagebreak
265 )
Hao Zhu71b30f22020-08-12 22:47:13 -0400266 ),
Hao Zhu12b0ade2018-01-13 16:19:58 -0500267 "major" = ifelse(
268 sum(as.numeric(midrule_matrix[i, ]) > 0) == ncol(midrule_matrix),
Hao Zhud0f7c8a2020-08-20 01:17:23 -0400269 paste0(midline_groups(which(as.numeric(midrule_matrix[i, ]) > 0),
270 table_info$booktabs), pagebreak_hint),
271 nopagebreak
georgeguieaeb0cd2018-03-30 17:39:46 -0500272 ),
273 "custom" = ifelse(
274 sum(as.numeric(midrule_matrix[i, custom_latex_hline])) > 0,
275 midline_groups(which(as.numeric(midrule_matrix[i, ]) > 0),
276 table_info$booktabs),
277 ""
Hao Zhu876bcb02020-08-12 23:02:51 -0400278 ),
279 "linespace"= ifelse(
280 sum(as.numeric(midrule_matrix[i, ]) > 0) == ncol(midrule_matrix),
Hao Zhud0f7c8a2020-08-20 01:17:23 -0400281 "\\\\addlinespace",
Hao Zhu876bcb02020-08-12 23:02:51 -0400282 ""
283 )
Hao Zhu12b0ade2018-01-13 16:19:58 -0500284 )
Hao Zhu654c91f2017-07-03 14:03:34 -0400285 new_contents[i] <- paste0(new_contents[i], "\\\\\\\\\n", row_midrule)
286 }
Hao Zhub3f26ae2020-08-04 00:36:52 -0400287 out <- sub(contents[i + 1], new_contents[i], out, perl=TRUE)
Hao Zhuf4b35292017-06-25 22:38:37 -1000288 }
Hao Zhuf4b35292017-06-25 22:38:37 -1000289 out <- structure(out, format = "latex", class = "knitr_kable")
290 table_info$collapse_rows <- TRUE
Hao Zhuebdb3c22020-08-12 08:27:38 -0400291 table_info$collapse_matrix <- collapse_matrix
Hao Zhuf4b35292017-06-25 22:38:37 -1000292 attr(out, "kable_meta") <- table_info
georgeguieaeb0cd2018-03-30 17:39:46 -0500293 if(row_group_label_position == 'stack'){
294 group_row_index_list <- collapse_rows_index(kable_dt, head(columns, -1))
295 out <- collapse_rows_latex_stack(out, group_row_index_list, row_group_label_fonts)
296 }
Hao Zhuf4b35292017-06-25 22:38:37 -1000297 return(out)
298}
299
Hao Zhuc9858942020-08-11 21:41:09 -0400300kable_dt_latex <- function(x, col_names) {
301 if (col_names) {
302 x <- x[-1]
303 }
304 data.frame(do.call(rbind, str_split(x, " & ")), stringsAsFactors = FALSE)
Hao Zhuf4b35292017-06-25 22:38:37 -1000305}
306
Hao Zhu5dd3e282018-05-20 18:39:48 -0400307collapse_new_dt_item <- function(x, span, width = NULL, align, valign) {
Hao Zhuf4b35292017-06-25 22:38:37 -1000308 if (span == 0) return("")
309 if (span == 1) return(x)
310 out <- paste0(
Hao Zhu5dd3e282018-05-20 18:39:48 -0400311 "\\\\multirow", valign, "\\{", -span, "\\}\\{",
Hao Zhuf4b35292017-06-25 22:38:37 -1000312 ifelse(is.null(width), "\\*", width),
313 "\\}\\{",
314 switch(align,
315 "l" = "\\\\raggedright\\\\arraybackslash ",
316 "c" = "\\\\centering\\\\arraybackslash ",
317 "r" = "\\\\raggedleft\\\\arraybackslash "),
318 x, "\\}"
319 )
320 return(out)
Hao Zhu2a87e8e2017-06-14 15:49:33 -0400321}
Hao Zhu654c91f2017-07-03 14:03:34 -0400322
323midline_groups <- function(x, booktabs = T) {
324 diffs <- c(1, diff(x))
325 start_indexes <- c(1, which(diffs > 1))
Hao Zhu12b0ade2018-01-13 16:19:58 -0500326 end_indexes <- c(start_indexes - 1, length(x))
Hao Zhu654c91f2017-07-03 14:03:34 -0400327 ranges <- paste0(x[start_indexes], "-", x[end_indexes])
328 if (booktabs) {
329 out <- paste0("\\\\cmidrule{", ranges, "}")
330 } else {
331 out <- paste0("\\\\cline{", ranges, "}")
332 }
333 out <- paste0(out, collapse = "\n")
334 return(out)
335}
georgeguieaeb0cd2018-03-30 17:39:46 -0500336
Hao Zhu876bcb02020-08-12 23:02:51 -0400337linespace_groups <- function(x) {
338 diffs <- c(1, diff(x))
339 start_indexes <- c(1, which(diffs > 1))
340 end_indexes <- c(start_indexes - 1, length(x))
341 ranges <- paste0(x[start_indexes], "-", x[end_indexes])
342 out <- paste0("\\\\addlinespace")
343 out <- paste0(out, collapse = "\n")
344 return(out)
345}
346
georgeguieaeb0cd2018-03-30 17:39:46 -0500347
348collapse_rows_index <- function(kable_dt, columns) {
349 format_to_row_index <- function(x){
350 x = rle(x)
351 out = x$lengths
352 names(out) = x$values
353 out
354 }
355 group_rows_index_list <- lapply(columns, function(x) {
356 format_to_row_index(kable_dt[, x])
357 })
358 return(group_rows_index_list)
359}
360
361
362collapse_rows_latex_stack <- function(kable_input, group_row_index_list,
363 row_group_label_fonts){
364 merge_lists <- function(default_list, updated_list){
365 for(x in names(updated_list)){
366 default_list[[x]] <- updated_list[[x]]
367 }
368 return(default_list)
369 }
370 default_font_list <- list(
371 list(bold = T, italic = F),
372 list(bold = F, italic = T),
373 list(bold = F, italic = F)
374 )
375 n_default_fonts = length(default_font_list)
376 n_supplied_fonts = length(row_group_label_fonts)
377 group_row_font_list <- list()
378 out <- kable_input
379 for(i in 1:length(group_row_index_list)){
380 if(i > n_default_fonts){
381 group_row_args <- default_font_list[[n_default_fonts]]
382 } else {
383 group_row_args <- default_font_list[[i]]
384 }
385 if(i <= n_supplied_fonts){
386 group_row_args <- merge_lists(group_row_args, row_group_label_fonts[[i]])
387 }
388 group_row_args <- merge_lists(
Hao Zhu718fa3f2020-08-19 08:23:28 -0400389 list(kable_input = out, index = group_row_index_list[[i]], escape = FALSE),
georgeguieaeb0cd2018-03-30 17:39:46 -0500390 group_row_args)
391 out <- do.call(group_rows, group_row_args)
392 }
393 return(out)
394}