Gt: Modify `cols_align()` to target column labels and possibly selections of cells

Created on 9 Dec 2018  Â·  5Comments  Â·  Source: rstudio/gt

Currently, cols_align() works on entire columns and there is no way to align the column labels differently than the data cells associated with the targeted columns. It would also be good to align certain cells differently.

All of this might involve incorporating either the rows or locations argument in order to target cells.

[3] Advanced [3] High [2] Medium ★ Enhancement

Most helpful comment

It’s sometimes more aesthetically pleasing to have centered headers with (1) columns that contain free-form text (usually these are wider columns), (2) in tables with many columns of mixed alignments, or (3) for column headers under a spanning column header (to center those column labels).

All 5 comments

Just curious--when would you want to align column labels different than their respective data cells?

It’s sometimes more aesthetically pleasing to have centered headers with (1) columns that contain free-form text (usually these are wider columns), (2) in tables with many columns of mixed alignments, or (3) for column headers under a spanning column header (to center those column labels).

Great, thanks for the clarification.

You’re welcome! I’ve seen some wonderful tables in books that do great stuff with different alignments. Unfortunately these examples are hard to find on the internet, but having the freedom for a few more styling choices like this I feel will go a long way.

We can modify the column labels’ alignment easily now with tab_style() so this update isn’t really needed anymore.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steveputman picture steveputman  Â·  3Comments

higgi13425 picture higgi13425  Â·  4Comments

jestarr picture jestarr  Â·  3Comments

vikram-rawat picture vikram-rawat  Â·  3Comments

mine-cetinkaya-rundel picture mine-cetinkaya-rundel  Â·  4Comments