1

The following code does not produce vertically aligned values in column 1, and does not group the value of column 2 at all. What am I doing wrong? I updated kableExtra and tried changing the order of the arguments to collapse_rows.

library(kableExtra)
library(knitr)

collapse_rows_dt <- data.frame(C1 = c(rep("a", 10), rep("b", 5)),
                           C2 = c(rep("c", 7), rep("d", 3), rep("c", 2), rep("d", 3)),
                           C3 = 1:15,
                           C4 = sample(c(0,1), 15, replace = TRUE))
collapse_rows_dt <- collapse_rows_dt[-11, ]
kable(collapse_rows_dt, "latex", align = "c") %>%
kable_styling(full_width = F) %>%
collapse_rows(columns = 1:2,
            latex_hline = "major",
            valign      = "middle",
            row_group_label_position = 'stack',
            row_group_label_fonts = list(list(bold = T), list(bold = T)))`

Should look similar to table top of page 17:

enter image description here

actual output:

enter image description here

1
  • 1
    What do you want it to look like in the end? A sketch or display of the first few lines would be helpful to understand. Thanks :)
    – mysteRious
    Jul 24, 2018 at 21:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.