Skip to content

Commit

Permalink
Merge branch 'master' into fmt-fraction
Browse files Browse the repository at this point in the history
* 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
  ...
  • Loading branch information
rich-iannone committed Jun 11, 2021
2 parents a0aa613 + bf1fba0 commit ccffd31
Show file tree
Hide file tree
Showing 148 changed files with 9,849 additions and 1,680 deletions.
7 changes: 3 additions & 4 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
^\.github$
^\.Rproj\.user$
^gt\.Rproj$
^\.travis\.yml$
^_pkgdown\.yml$
^appveyor\.yml$
^codecov\.yml$
^README\.Rmd$
^README\.md$
^LICENSE\.md$
^CODE_OF_CONDUCT\.md$
^TODOS
tests/gt-examples
vignettes
man/figures/.*svg$
man/figures/[^m].*png$
133 changes: 133 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in
our community a harassment-free experience for everyone, regardless of
age, body size, visible or invisible disability, ethnicity, sex
characteristics, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open,
welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our
mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political
attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our
standards of acceptable behavior and will take appropriate and fair
corrective action in response to any behavior that they deem
inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other
contributions that are not aligned to this Code of Conduct, and will
communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also
applies when an individual is officially representing the community in
public spaces. Examples of representing our community include using an
official e-mail address, posting via an official social media account,
or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may
be reported to the community leaders responsible for enforcement at
[rich@rstudio.com](mailto:rich@rstudio.com). All
complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security
of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in
determining the consequences for any action they deem in violation of
this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior
deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders,
providing clarity around the nature of the violation and an explanation
of why the behavior was inappropriate. A public apology may be
requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, for a specified period of
time. This includes avoiding interactions in community spaces as well as
external channels like social media. Violating these terms may lead to a
temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards,
including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No
public or private interaction with the people involved, including
unsolicited interaction with those enforcing the Code of Conduct, is
allowed during this period. Violating these terms may lead to a
permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of
individuals.

**Consequence**: A permanent ban from any sort of public interaction
within the community.

## Attribution

This Code of Conduct is adapted from the
[Contributor Covenant][homepage], version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ
at https://www.contributor-covenant.org/faq. Translations are available
at https://www.contributor-covenant.org/translations.
25 changes: 0 additions & 25 deletions CODE_OF_CONDUCT.md

This file was deleted.

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Type: Package
Package: gt
Version: 0.2.2
Version: 0.3.0.9000
Title: Easily Create Presentation-Ready Display Tables
Description: Build display tables from tabular data with an easy-to-use set of
functions. With its progressive approach, we can construct display tables
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ export(escape_latex)
export(everything)
export(extract_summary)
export(fmt)
export(fmt_bytes)
export(fmt_currency)
export(fmt_date)
export(fmt_datetime)
export(fmt_fraction)
export(fmt_engineering)
export(fmt_integer)
export(fmt_markdown)
export(fmt_missing)
export(fmt_number)
Expand Down
71 changes: 69 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
# gt (development version)

# gt 0.3.0

This release focuses on improvements to two main areas:

1. Better RTF output support:
* RTF table generation is now fit for use following an extensive rewrite of internal RTF rendering functions.
* RTF table output with `gtsave(..., "<file>.rtf")` and `as_rtf()` now has much more feature parity compared to HTML tables; we can now add summary rows, format table text with Markdown via `fmt_markdown()`, and expect tables that look acceptable in Word and text editors that are RTF-compatible.

2. Implementation of **tidyselect** semantics:
* References to columns (by way of the `columns` argument in many **gt** functions) now better adhere to **tidyselect** semantics.
* Instead of using `columns = vars(a, b)`, we now use `columns = c(a, b)` (`columns = c("a", "b")` also works, and this type of expression always has been an option in **gt**).
* Other **tidyselect** idioms should also work; things like using `where()` to target columns (e.g., `gt(exibble) %>% cols_hide(columns = where(is.numeric))` will hide all numeric columns) and negation (e.g., `columns = -c(a, b)`) function as expected.

## Breaking changes and deprecations

* Column labels subordinate to column spanner labels had their alignment forced to be `"center"` but now there is no specialized alignment of column labels under spanners. Should you need the old behavior, `tab_style()` can be used along with `cell_text(align = "center")` for all columns that live under spanners. (#662)

* The automatic alignment of integer values has been changed from `"center"` to `"right"`. To correct for this, use `tab_style()` with `cell_text(align = "center")` for all affected columns. (#662)

* As part of the **tidyselect** changes made in this release, using `columns = TRUE` (to mean that all columns should be considered) has now been replaced with `columns = everything()`. Using the former will result in a warning message. (#718)

* While `vars()` is still reexported in **gt**, its use with the `columns` argument (present in a large number of functions) is deprecated and a warning message will appear if it is used. In a later release, it can be expected that `vars()` will no longer be reexported. (#718)

* The `others_label` argument of `tab_row_group()` is deprecated since it was confusing to use. To specify a default label for row groups, the course of action is now to use `tab_options(row_group.default_label = <label>)`. (#699)

## New features

* RTF table output via `gtsave(..., "<file>.rtf")` and `as_rtf()` should produce more robust tables (allowing use of `summary_rows()`, `fmt_markdown()`, etc.). And tables generated as RTF can now take advantage of `cols_width()` for flexible modifications of column widths. (#638 and #696)

* All functions with a `columns` argument can now take advantage of **gt**'s full adherence to **tidyselect** semantics (use `columns = c(a, b)` or `columns = c("a", "b")` instead of `columns = vars(a, b)`). (#718)

* New location helper functions have been added to make it possible to style more locations and add footnotes to once inaccessible locations; these are `cells_stub_summary()`, `cells_stub_grand_summary()`, `cells_footnotes()`, and `cells_source_notes()`. Note that footnotes cannot be declared with the latter two functions. (#737)

* The `cols_unhide()` function has been added as a complement to the `cols_hide()` function. This is useful when provided the `gt_tbl` object without the source data and code to recreate it *and* there are hidden columns that should be made visible. (#710)

* The new formatting function `fmt_bytes()` helps you to transform numerical values to byte sizes with human readable units. (#750)

* A new column merging function, `cols_merge_n_pct()`, works to merge a count column and a percentage column together. This function will automatically hide the `col_pct` column by default (but that can be changed by setting `autohide = FALSE`). (#683)

* Added the `caption` argument to `gt()`. This brings caption support to **gt** tables in R Markdown and **bookdown** documents. (#689)

## Minor improvements

* The `accounting` option is now available in the `fmt_percent()` and `fmt_number()` formatting functions (previously it was only present in `fmt_currency()`). (#756)

* In RTF documents generated through `as_rtf()` and `gtsave(..., filename = "<file>.rtf")`, there is now a `page_numbering` option for adding page numbers to either the `"footer"` or the `"header"` areas (the default is `"none"`). (#755)

* `tab_spanner_delim()` gained a `split` argument to govern whether delimiter splitting should occur at the `"first"` or `"last"` instance of `delim`. For example, if the column name `"a.b.c"` is present and `split = "first"` then the spanner column label is `"a"` and the associated column label will be `"b.c"`; should `split = "last"` then the spanner and column will have `"a.b"` and `"c"` labels. (#699)

* Added `id` as an argument to `tab_spanner()` and `tab_row_group()`, which is useful for later access to these locations (especially when spanner or row group labels are complicated). (#665, #699)

* HTML table generation is much faster due to efforts to optimize HTML code generation in the building/rendering phase. (#664)

## Bug fixes

* When getting the HTML text for **gt** table with `as_raw_html(..., inline_css = FALSE)`, the `<style>` tag content is no longer omitted. (#718)

* Fixed two bugs in `tab_row_group()`: (1) incorrect reordering of rows (Issue #717), and (2) spurious warnings with multiple calls (Issue #675). (#699)

* The `tab_spanner_delim()` with `gather = TRUE` did not work reliably (Issue #626) but was fixed along with other work done to overhaul the function. (#665)

* Correction made to the representation of the `PEN` (Peruvian Neuvo Sol) currency. (#663)

* Fix for `gtsave()` when saving an image and specifying a `path` value. (#592)

# gt 0.2.2

## New features
Expand All @@ -20,15 +87,15 @@

* Restore the ability to have row striping in stub cells (with `tab_option()`'s `row.striping.include_stub = TRUE`). Thanks @gergness for creating PR #537, which prompted this final fix. (#564)

# gt 0.2.1 (2020-05-26)
# gt 0.2.1

* `summary_rows()` and `grand_summary_rows()` no longer incorrectly calculate summary values in cases where rows aren't already sorted by group (#556).

* Ensure compatibility with **tibble** 3.0.0. (#557)

* Adapt tests to changes in dependent packages. (#575)

# gt 0.2.0.5 (2020-03-31)
# gt 0.2.0.5

* New package with 80 exported functions for building display tables

Expand Down
2 changes: 1 addition & 1 deletion R/data_color.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
#'
#' @family Format Data
#' @section Function ID:
#' 3-13
#' 3-15
#'
#' @import rlang
#' @export
Expand Down
9 changes: 9 additions & 0 deletions R/datasets.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#' Yearly populations of countries from 1960 to 2017
#'
#' @description
#' A dataset that presents yearly, total populations of countries. Total
#' population is based on counts of all residents regardless of legal status or
#' citizenship. Country identifiers include the English-language country names,
Expand Down Expand Up @@ -31,12 +32,14 @@

#' Twice hourly solar zenith angles by month & latitude
#'
#' @description
#' This dataset contains solar zenith angles (in degrees, with the range of
#' 0-90) every half hour from 04:00 to 12:00, true solar time. This set of
#' values is calculated on the first of every month for 4 different northern
#' hemisphere latitudes. For determination of afternoon values, the presented
#' tabulated values are symmetric about noon.
#'
#' @details
#' The solar zenith angle (SZA) is one measure that helps to describe the sun's
#' path across the sky. It's defined as the angle of the sun relative to a line
#' perpendicular to the earth's surface. It is useful to calculate the SZA in
Expand Down Expand Up @@ -77,12 +80,14 @@

#' Deluxe automobiles from the 2014-2017 period
#'
#' @description
#' Expensive and fast cars. Not your father's `mtcars`. Each row describes a car
#' of a certain make, model, year, and trim. Basic specifications such as
#' horsepower, torque, EPA MPG ratings, type of drivetrain, and transmission
#' characteristics are provided. The country of origin for the car manufacturer
#' is also given.
#'
#' @details
#' All of the `gtcars` have something else in common (aside from the high asking
#' prices): they are all grand tourer vehicles. These are proper GT cars that
#' blend pure driving thrills with a level of comfort that is more expected from
Expand Down Expand Up @@ -126,6 +131,7 @@

#' Daily S&P 500 Index data from 1950 to 2015
#'
#' @description
#' This dataset provides daily price indicators for the S&P 500 index from the
#' beginning of 1950 to the end of 2015. The index includes 500 leading
#' companies and captures about 80\% coverage of available market capitalization.
Expand All @@ -152,6 +158,7 @@

#' A year of pizza sales from a pizza place
#'
#' @description
#' A synthetic dataset that describes pizza sales for a pizza place somewhere in
#' the US. While the contents are artificial, the ingredients used to make the
#' pizzas are far from it. There are 32 different pizzas that fall into 4
Expand All @@ -163,6 +170,7 @@
#' whatsoever: 'My Five Cheese pizza has so many cheeses, I can only offer it in
#' Large Size!').
#'
#' @details
#' Each pizza in the dataset is identified by a short `name`. The following
#' listings provide the full names of each pizza and their main ingredients.
#'
Expand Down Expand Up @@ -278,6 +286,7 @@

#' A toy example tibble for testing with gt: exibble
#'
#' @description
#' This tibble contains data of a few different classes, which makes it
#' well-suited for quick experimentation with the functions in this package. It
#' contains only eight rows with numeric, character, and factor columns. The
Expand Down
2 changes: 1 addition & 1 deletion R/dt_heading.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ dt_heading_has_subtitle <- function(data) {

heading <- dt_heading_get(data = data)

length(heading) > 0 && length(heading$subtitle) > 0 && !is.null(heading$subtitle)
length(heading) > 0 && is_nonempty_string(heading$subtitle)
}

0 comments on commit ccffd31

Please sign in to comment.