gpt4 book ai didi

R Notebook:并排放置 knitr::kable 表格?

转载 作者:行者123 更新时间:2023-12-05 01:17:27 25 4
gpt4 key购买 nike

我在 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()

关于R Notebook:并排放置 knitr::kable 表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50277529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com