首页 > 解决方案 > 右对齐 gt 中的 rowname_col

问题描述

我想右对齐,rowname_col但看起来你不能应用于cols_align行名?

tibble(
  one = c("Long names", "Other Name", "Name | Name"),
  two = 1:3
) %>% gt(rowname_col = "one") %>%
  cols_align(align = "right", columns = vars(one))

在此处输入图像描述

标签: rgt

解决方案


您可以像这样右对齐 rowname 列:

library(dplyr)
library(gt)

tibble(
  one = c("Long names", "Other Name", "Name | Name"),
  two = 1:3
) %>% gt(rowname_col = "one") %>%
  tab_style(
    style = list(
      cell_text(align = "right")
    ),
    locations = cells_stub(rows = TRUE)
  )

在此处输入图像描述


推荐阅读