将 save_kable() 保存为白色背景而不是默认灰色的 png

Save save_kable() to png with white background instead of default gray

我只需要将整个table的背景色改成白色即可。一个可重现的例子

kable(head(iris)) %>%
  kable_styling("striped", full_width = FALSE, htmltable_class = 'lightable-classic-2') %>%
  add_header_above(c("Measurements" = 4L, " " = 1L)) %>% 
  kable_paper() %>%
  save_kable(file = 'tableX.png') 

有什么 found/tried:

您可以在 bootswatch.com 找到一些 bs_theme 的示例 对于我的示例,我使用了 flatly.

library(kableExtra)


kable(head(iris)) %>%
  kable_styling("striped", full_width = FALSE, htmltable_class = 'lightable-classic-2') %>%
  add_header_above(c("Measurements" = 4L, " " = 1L)) %>% 
  kable_paper() %>%
  save_kable(file = 'tableX.png', bs_theme = "flatly")