Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right align the rowname_col in gt

Tags:

I'd like to right align the rowname_col but it doesn't look like you can apply cols_align to rownames?

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

enter image description here

like image 652
MayaGans Avatar asked May 18 '20 22:05

MayaGans


1 Answers

You can right align the rowname column like so:

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

enter image description here

like image 183
stefan Avatar answered Sep 21 '22 18:09

stefan