右对齐 gt 中的 rowname_col

Right align the rowname_col in gt

我想将 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))

您可以像这样右对齐行名列:

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)
  )