Home > Software engineering >  First row are consider as column name in kableExtra using pack_rows after removing variable names
First row are consider as column name in kableExtra using pack_rows after removing variable names

Time:11-10

My problem starts when I create groupings on a unnamed table of variables with the kableExtra::pack_rows() function. The problem, which you will notice if you render the code, is that row number 1 became the column of the table, being out of the grouping I want. In pack_rows () the argument start_row = 0 is not possibl

library(kableExtra)

my_data <-  mtcars[1:5, 1:6]

my_data %>%
kbl(caption = "without col.names, with groups", col.names = NULL) %>%
kable_styling(bootstrap_options = c("striped", "hover"), latex_options = "hold_position") %>%
pack_rows("Index 1",1, 3) %>%
pack_rows("Index 2",4, 4)

enter image description here

CodePudding user response:

How is not possible?

(In the RMarkdown you can assign start_row = 0, in the console - yes, only from 1. But there I didn't see your problem)

my_data <-  mtcars[1:5, 1:6]

my_data %>%
kbl(caption = "without col.names, with groups", col.names = NULL) %>%
kable_styling(bootstrap_options = c("striped", "hover"), latex_options = c("hold_position")) %>%
pack_rows("Index 1",0, 2) %>%
pack_rows("Index 2",3, 4)

After knitting to .pdf:

enter image description here

  • Related