R笔记本电脑:将可折叠的桌子并排放置?
我在R笔记本上写下了一些数字和表格,我有几张桌子想并排放置。我正在把笔记本编织成一个html。我现在使用的代码(如下)是有效的,但两个表都是左对齐的。我真正想要的是他们并排出现,但也要居中。有什么建议吗?dt_tot和dt_tot_week是数据表R笔记本电脑:将可折叠的桌子并排放置?,r,knitr,kable,rnotebook,kableextra,R,Knitr,Kable,Rnotebook,Kableextra,我在R笔记本上写下了一些数字和表格,我有几张桌子想并排放置。我正在把笔记本编织成一个html。我现在使用的代码(如下)是有效的,但两个表都是左对齐的。我真正想要的是他们并排出现,但也要居中。有什么建议吗?dt_tot和dt_tot_week是数据表 knitr::kable(dt_tot, "html", caption = caption) %>% kableExtra::kable_styling(bootstrap_options = c("hover"),
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")
您只需要将dt_tot_week形成的表的位置更改为向右浮动,而不是向左浮动。我敢肯定那一定是你的代码输入错误
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")
如果您正在编织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,而不是html,但它确实可以做到这一点:)