Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the fmt_engineering() and fmt_integer() formatter functions #758

Merged
merged 19 commits into from
Jun 7, 2021

Conversation

rich-iannone
Copy link
Member

@rich-iannone rich-iannone commented May 7, 2021

The fmt_engineering() formatter function allows for numeric values to be rendered in engineering notation. This is similar in many ways to scientific notation except that powers of 10 increase/decrease by three (in line with SI prefixes larger than 3 and smaller than -3). As a consequence, the floating point number part can be in the range of 1 to <1000. Here an example that uses digits that span over a large range:

library(gt)
library(tidyverse)

dplyr::tibble(
  a = c(
    0, 0.000001, 0.00002, 0.0003, 0.004, 0.05, 0.6,
    7, 88, 99, 1000, 15000, 150000, 1500000, 15000000,
    150000000, 1500000000, 15000000000, 150000000000,
    1500000000000, 15000000000000, 150000000000000, NA
  )
) %>% 
  gt() %>%
  fmt_engineering(columns = a)

fmt_engineering

This PR also adds the fmt_integer() function.

Fixes: #780
Fixes: #774

* master:
  Add `accounting` options for `fmt_percent()` and `fmt_number()` (#756)
  Simplify arguments for RTF page numbering
  Simplify page numbering text
  Add testthat snapshot tests for RTF page numbering
  Swap location options, putting 'footer' first
  Update help files using roxygen
  Enhance `as_rtf()` and `gt_save_rtf()`
  Incorporate page numbering in `rtf_file()`
* pkgdown-add-topics:
  Add missing topics to _pkgdown.yml
* master:
  Reinstate once failing test
  Include stub var in resolution of visible vars
  Use `seq_len()` instead of `seq()`
  Fix typo in README (#765)
  Increment version number (#762)
  Increase version number
  Documentation fixes (#759)
* master:
  LaTeX bugfix for summary rows, and, implementation of grand summary rows (#768)
@rich-iannone rich-iannone changed the title Add the fmt_engineering() formatter function Add the fmt_engineering() and fmt_integer() formatter functions May 28, 2021
@rich-iannone rich-iannone marked this pull request as ready for review May 28, 2021 23:12
@rich-iannone rich-iannone merged commit 811880e into master Jun 7, 2021
@rich-iannone rich-iannone deleted the fmt-engr branch June 7, 2021 19:29
rich-iannone added a commit that referenced this pull request Jun 7, 2021
* master:
  Add the `fmt_engineering()` and `fmt_integer()` formatter functions (#758)
  HTML summary row styling fix (#782)
  Refactor and improve rendering of title/subtitle components in HTML/LaTeX tables (#779)
rich-iannone added a commit that referenced this pull request Jun 11, 2021
* master: (24 commits)
  Fix for possible column name duplication when generating summary rows (#792)
  Change the `data` arg to `.data` to avoid partial matching issues (#772)
  Add the `force_sign` arg to several numeric formatters (#793)
  Add the `fmt_engineering()` and `fmt_integer()` formatter functions (#758)
  HTML summary row styling fix (#782)
  Refactor and improve rendering of title/subtitle components in HTML/LaTeX tables (#779)
  LaTeX bugfix for summary rows, and, implementation of grand summary rows (#768)
  Reinstate once failing test
  Include stub var in resolution of visible vars
  Use `seq_len()` instead of `seq()`
  Fix typo in README (#765)
  Increment version number (#762)
  Increase version number
  Documentation fixes (#759)
  Add missing topics to _pkgdown.yml
  Add `accounting` options for `fmt_percent()` and `fmt_number()` (#756)
  Simplify arguments for RTF page numbering
  Add the `fmt_bytes()` formatter function (#750)
  Simplify page numbering text
  Add testthat snapshot tests for RTF page numbering
  ...
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.

Add the fmt_engineering() function to get values in engineering notation Add the fmt_integer() function
2 participants