I'm using kableExtra
package to make tables. Inside pack_rows()
, I wanted to use an object that I set outside pack_rows()
as the group index.
Here is an reproducible example:
This is an option, where you manually set the group index as "Mazda Cars"
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kbl(dt) %>%
kable_paper("striped", full_width = F) %>%
pack_rows(index = c("Mazda Cars" = 2,
"Other Cars" = 3
))
However, I tried creating an object that contains "Mazda Cars"
, but the table group index shows "group_1" instead of Mazda
dt <- mtcars[1:5, 1:6]
group_1 <- "Mazda"
kbl(dt) %>%
kable_paper("striped", full_width = F) %>%
pack_rows(index = c(group_1 = 2,
"Other Cars" = 3
))
I believe this has something to do with interpretation of vector names, but I don't quite remember what.
Help much appreciated,
Thank you.