Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rich-iannone
Copy link
Member

This PR fixes a longstanding issue where column labels subordinate to column spanner labels had their alignment forced to be "center". This resulted in a balanced spanner-label/column-label assembly but the misalignment between such column labels and their data cells resulted in a worse appearance (especially magnified as column widths were increased). Furthermore, the center alignment was at odds with what the community wanted and was contrary to advice from experts on the matter. Now there is no forced alignment of column labels.

Should you need the old behavior, tab_style() can be used along with cell_text(align = "center").

This PR also changes to automatic alignment of integer values from "center" to "right". This was another oversight but is corrected now.

An example plot, using the airquality dataset is shown below:

gt(data = airquality) %>%
  cols_move_to_start(columns = vars(Month, Day)) %>%
  cols_label(Solar.R = html("Solar<br>Radiation")) %>%
  fmt_number(
    columns = vars(Wind),
    decimals = 2
  ) %>%
  tab_spanner(
    label = "Measurement Period",
    columns = vars(Month, Day)
  ) %>%
  fmt_missing(columns = vars(Ozone, Solar.R, Wind, Temp)) %>%
  tab_options(table.width = "100%")

airquality_gt

Fixes: #607

@rich-iannone rich-iannone requested a review from jcheng5 October 19, 2020 17:28
Copy link
Member

@jcheng5 jcheng5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests

@rich-iannone rich-iannone requested a review from jcheng5 October 21, 2020 14:58
@rich-iannone rich-iannone merged commit 35355c4 into master Oct 24, 2020
@rich-iannone rich-iannone deleted the spanner-alignment-correct branch October 24, 2020 01:07
rich-iannone added a commit that referenced this pull request Oct 25, 2020
* master: (30 commits)
  Spanner alignment correction (#662)
  PEN currency fix (#663)
  Fix for `gtsave()` when saving an image and specifying a `path` value (#592)
  Rewrite of RTF building functions and `as_rtf()` (#638)
  v0.2.2 Release Candidate (#629)
  Settable font options (#591)
  Add options for sig figs / inclusion of trailing dec marks (#546)
  Fix issues with defining column widths in `cols_width()` (#561)
  Add `scale_values` arg to `fmt_percent()` (#565)
  Restore row striping option in stub cells (`row.striping.include_stub = TRUE`) (#564)
  Refactor `data_color()` so that it executes faster (#576)
  Update R-CMD-check.yaml (#599)
  Release gt 0.2.1 (#588)
  Ensure that row ordering doesn't affect summary row calculations (#556)
  Update failing example (#586)
  Remove test of scales behaviour
  Squelch warnings from tibble 3.0.0/3.0.1 (#557)
  Bump cache on pkgdown.yaml for GH workflow (#570)
  Update GH Actions workflow for R CMD check (#568)
  Update Description of package to be less confusing (#569)
  ...
rich-iannone added a commit that referenced this pull request Oct 25, 2020
* master:
  Spanner alignment correction (#662)
  PEN currency fix (#663)
  Fix for `gtsave()` when saving an image and specifying a `path` value (#592)
rich-iannone added a commit that referenced this pull request Nov 2, 2020
* master:
  Spanner alignment correction (#662)
  PEN currency fix (#663)
  Fix for `gtsave()` when saving an image and specifying a `path` value (#592)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tab_spanner() and column misalignment

3 participants