【发布时间】:2022-12-30 14:00:00
【问题描述】:
我在 pdf 文档中使用 R markdown,使用 gt() 在底部制作一个带有源注释的表格。出于某种原因,源注释未与表格居中对齐。如何使其与表格对齐?
这是我编织 PDF 文档时出现的结果,源注释在左侧,而不是与表格居中。
这是我的数据框:
test_df<-
structure(list(Year = c("2010", "2015", "2020"), Lehigh_County = c(350008,
359689, 374557), Northampton_County = c(297941, 300264, 312951
), Lehigh_Valley = c(647949, 659953, 687508)), row.names = c(NA,
-3L), class = c("tbl_df", "tbl", "data.frame"))
这是将其变成 gt 表的代码:
test_df %>%
gt() %>%
tab_header(
title = "Lehigh Valley Population Forecast",
subtitle = "2020 - 2050"
) %>%
cols_label(
Lehigh_County = "Lehigh County",
Northampton_County = "Northamp. County",
Lehigh_Valley = "Lehigh Valley"
) %>%
tab_source_note(source_note = "U.S. Census / REMI Forecasts") %>%
fmt_number(columns = c(Lehigh_County, Northampton_County, Lehigh_Valley), sep_mark = ",", decimals = 0)
当我生成表格时它看起来是正确的,但是当我编织时,源注释向左移动。有什么建议吗?
【问题讨论】:
标签: r r-markdown gt