英文:
flextable: align ONLY header row to center
问题
我有以下的代码,结果如下图所示。
然而,我希望 header_row
在列上居中对齐(作为参数传递的 colwidths
,我一直在搜索,咨询手册(但我是 R 新手,所以我的理解很差),但我感到困惑。表中的其他所有内容都应该保持其原有的对齐方式。
ft <- flextable(df_BAS_sum)
ft <- set_caption(ft, caption = sprintf("Tabell 1. Arbetsmarknadsdata och nyckeltal för olika geografier, 20-64 år - %s %s", month, yr), align_with_table = FALSE)
ft <- add_header_row(ft, colwidths = c(1,2,4,3), values = c("","Arbetskraften","Ej i arbetskraften","Nyckeltal"))
ft <- colformat_num(x = ft,
big.mark = " ", decimal.mark = ",",
na_str = "N/A")
ft <- theme_vanilla(ft)
ft
感谢任何见解!
英文:
I have the following code which results in below fig.
However I want the header_row
to align center over the cols.(passed as arg.:colwidths
, I've been searching, consulted the manual (but I'm new to R so my understanding is bad), but I'm at a lost. Everything else in the table should have the alignment it has.
ft <- flextable(df_BAS_sum)
ft <- set_caption(ft, caption =sprintf("Tabell 1. Arbetsmarknadsdata och nyckeltal för olika geografier, 20-64 år - %s %s", month, yr), align_with_table = F)
ft <- add_header_row(ft, colwidths = c(1,2,4,3), values = c("","Arbetskraften","Ej i arbetskraften","Nyckeltal"))
ft <- colformat_num(x = ft,
big.mark=" ", decimal.mark = ",",
na_str = "N/A")
ft <- theme_vanilla(ft)
ft
Thanks for any insight!
答案1
得分: 3
part = "header"
限定了它仅适用于标题行
i = 1
(第一行)
j = NULL
(所有列)应避免对其他标题行进行不必要的重新对齐。
英文:
ft <- align(ft, i = 1, j = NULL, align = "center", part = "header")
part = "header"
restricts it to the header rows only
i = 1
(first row)
j = NULL
(all columns) should avoid the undesirable realignment of the other header row.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论