Hao Zhu | f4b3529 | 2017-06-25 22:38:37 -1000 | [diff] [blame] | 1 | --- |
| 2 | title: "Untitled" |
Hao Zhu | 654c91f | 2017-07-03 14:03:34 -0400 | [diff] [blame] | 3 | output: |
| 4 | pdf_document: |
| 5 | keep_tex: true |
Hao Zhu | f4b3529 | 2017-06-25 22:38:37 -1000 | [diff] [blame] | 6 | --- |
| 7 | |
| 8 | ```{r} |
| 9 | library(knitr) |
Hao Zhu | 71b30f2 | 2020-08-12 22:47:13 -0400 | [diff] [blame^] | 10 | library(dplyr) |
Hao Zhu | f4b3529 | 2017-06-25 22:38:37 -1000 | [diff] [blame] | 11 | library(kableExtra) |
| 12 | collapse_rows_dt <- data.frame(C1 = c(rep("aaaaaa aaaaaa", 10), rep("bbbbb bbbbbb", 5)), |
Hao Zhu | 71b30f2 | 2020-08-12 22:47:13 -0400 | [diff] [blame^] | 13 | C2 = c(rep("c", 7), rep("d", 3), rep("c", 3), rep("d", 2)), |
Hao Zhu | f4b3529 | 2017-06-25 22:38:37 -1000 | [diff] [blame] | 14 | C3 = 1:15, |
| 15 | C4 = sample(c(0,1), 15, replace = TRUE)) |
Hao Zhu | 71b30f2 | 2020-08-12 22:47:13 -0400 | [diff] [blame^] | 16 | kable(bind_rows(collapse_rows_dt, collapse_rows_dt, collapse_rows_dt, collapse_rows_dt), "latex", align = "c", booktabs = T, longtable= T) %>% |
Hao Zhu | 654c91f | 2017-07-03 14:03:34 -0400 | [diff] [blame] | 17 | column_spec(1, bold = T, width = "5em") %>% |
Hao Zhu | 71b30f2 | 2020-08-12 22:47:13 -0400 | [diff] [blame^] | 18 | collapse_rows(1:2, latex_hline = "full", longtable_clean_cut = T) %>% |
| 19 | cat() |
Hao Zhu | f4b3529 | 2017-06-25 22:38:37 -1000 | [diff] [blame] | 20 | ``` |