how to combine multiple html (kable) tables into one image?

心已入冬 提交于 2019-12-24 15:15:19

问题


I would like to combine several kable tables into one single image. Something like:

library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:4]

# first table
table1 <- kable(dt, format = "html", caption = "Demo Table") %>%
  kable_styling(bootstrap_options = "striped",
                full_width = F) %>%
  add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>%
  add_footnote(c("table footnote"))

# second table
table2 <- kable(dt, format = "html", caption = "Demo Table") %>%
  kable_styling(bootstrap_options = "striped",
                full_width = F) %>%
  add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>%
  add_footnote(c("table footnote"))

and put table1 on top of table2 in an image:

bind_rows(table1, table2) %>% 
  kable_as_image(., filename = 'P:/mytable/table')

However, this does not work. How can I do that? Thanks!

来源:https://stackoverflow.com/questions/54025177/how-to-combine-multiple-html-kable-tables-into-one-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!