我在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")
答案 0 :(得分:1)
如果要编织成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()
答案 1 :(得分:0)
您只需要将dt_tot_week形成的表的位置更改为float_right而不是float_left。我敢肯定您的代码一定是错字。
knitr::kable(dt_tot, "html", caption ="left Tbl") %>%
kableExtra::kable_styling(bootstrap_options = c("hover"),
full_width = FALSE, position = "float_left")
knitr::kable(dt_tot_week, "html", caption ="right Tbl") %>%
kableExtra::kable_styling(bootstrap_options = c("hover"),
full_width = FALSE, position = "float_right")