R 笔记本:并排放置 knitr::kable 表格?

ast*_*son 4 r knitr rnotebook kableextra kable

我正在 R 笔记本中写一些数字和表格,并且我有一些表格想要并排放置。我正在将笔记本编织成 html。我现在的代码(如下)可以工作,但是两个表都是左对齐的。我真正想要的是让它们并排出现但又居中。请问有什么建议吗?dt_tot 和 dt_tot_week 是 data.tables。

knitr::kable(dt_tot, "html", caption = caption) %>%
  kableExtra::kable_styling(bootstrap_options = c("hover"),
                            full_width = FALSE, position = "float_left")

knitr::kable(dt_tot_week, "html", caption = caption) %>%
kableExtra::kable_styling(bootstrap_options = c("hover"),
                          full_width = FALSE, position = "float_left")
Run Code Online (Sandbox Code Playgroud)

Ama*_*nda 9

如果您要编写 HTML,您应该能够使用knitr::kables. 这给了我两张并排的桌子:

library(tidyverse)
library(kableExtra)

knitr::kables(list(
  kable(caption = "Left Table",
    starwars %>%
      count(species) %>%
      filter(n > 1)
    ) %>% kable_styling(),
    kable(caption = "Right Table",
      starwars %>%
        count(homeworld) %>%
        filter(n > 1)
    ) %>% kable_styling()
    
  )
) %>% kable_styling()
Run Code Online (Sandbox Code Playgroud)