[英]R Notebook: place knitr::kable tables side-by-side?
我正在 R Notebook 中编写一些图形和表格,并且我想并排放置一些表格。 我正在将笔记本编织成 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")
如果你正在编织 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()
您只需要将 dt_tot_week 形成的 table 的位置更改为 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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.