commit | 2a87e8e7e78ee72b467f901cb83edeb79c10aabc | [log] [tgz] |
---|---|---|
author | Hao Zhu <haozhu233@gmail.com> | Wed Jun 14 15:49:33 2017 -0400 |
committer | Hao Zhu <haozhu233@gmail.com> | Wed Jun 14 15:49:33 2017 -0400 |
tree | ece58fd75edf216340da035bb05de0b4228e0b2b | |
parent | 03487ef93ed28d4bd9020ba9ce2ebdf82671d927 [diff] [blame] |
add collapse_rows html
diff --git a/R/util.R b/R/util.R index 90c84bc..3f5c470 100644 --- a/R/util.R +++ b/R/util.R
@@ -55,3 +55,15 @@ latex_row_cells <- function(x) { strsplit(x, " \\& ") } + +collapse_row_matrix <- function(kable_dt, columns) { + mapping_matrix <- list() + for (i in columns) { + mapping_matrix[[paste0("x", i)]] <- unlist(lapply( + rle(kable_dt[, i])$length, function(x) { + c(x, rep(0, x - 1)) + })) + } + mapping_matrix <- data.frame(mapping_matrix) + return(mapping_matrix) +}