Skip to content
Easily generate information-rich, publication-quality tables from R
R CSS
Branch: master
Clone or download
Latest commit efaee2d Sep 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update CLA text (#373) Sep 13, 2019
R CSS modifications (#346) Aug 8, 2019
data-raw Update of the `info_paletteer()` info table (#186) Feb 22, 2019
data Regenerate .rda files Dec 31, 2018
inst Fix for invisible top borders in rendered HTML tables (#359) Aug 16, 2019
man CSS modifications (#346) Aug 8, 2019
pkgdown/favicon pkgdown cleanup (#226) Mar 14, 2019
tests Fix for invisible top borders in rendered HTML tables (#359) Aug 16, 2019
vignettes Easier access to footnote mark options (#333) Aug 1, 2019
.Rbuildignore Modify .Rbuildignore Dec 31, 2018
.gitignore pkgdown cleanup (#226) Mar 14, 2019
.travis.yml Several `rlang`-based fixes (#334) Aug 1, 2019
API Update API listing Jan 31, 2019
CODE_OF_CONDUCT.md Add Code of Conduct .md document Mar 23, 2018
DESCRIPTION remove reliance on Github version of sass, which is now updated on CR… Sep 13, 2019
LICENSE Modify information in LICENSE May 30, 2018
LICENSE.md Use better-formatted MIT license (.md) Dec 20, 2018
NAMESPACE Easier access to footnote mark options (#333) Aug 1, 2019
NEWS.md Update NEWS.md Nov 18, 2018
README.Rmd Update README (#219) Mar 13, 2019
README.md Update README (#219) Mar 13, 2019
_pkgdown.yml Adding the `currency()` helper function for specifying custom currenc… May 7, 2019
appveyor.yml Modify Appveyor YAML file Jan 31, 2019
codecov.yml Add codecov token Nov 2, 2018
gt.Rproj Update .Rproj file Mar 29, 2018

README.md

gt

lifecycle CRAN status Travis build status AppVeyor Build Status Coverage status

With the gt package, anyone can make wonderful-looking tables using the R programming language. The gt philosophy: we can construct a wide variety of useful tables with a cohesive set of table parts. These include the table header, the stub, the stub head, the column labels, the table body, and the table footer.

It all begins with preprocessed table data (be it a tibble or a data frame). You decide how to compose your gt table with the elements you need for the task at hand. Output can either be in the form of HTML, LaTeX, or RTF. All work beautifully inside R Markdown documents.

The gt API is designed to be both straightforward yet powerful. The emphasis is on simple functions for the everyday display table needs. Here is a brief example of how to use gt to create an HTML gt Table from the included sp500 dataset:

library(gt)
library(tidyverse)
library(glue)

# Define the start and end dates for the data range
start_date <- "2010-06-07"
end_date <- "2010-06-14"

# Create a gt table based on preprocessed
# `sp500` table data
sp500 %>%
  dplyr::filter(date >= start_date & date <= end_date) %>%
  dplyr::select(-adj_close) %>%
  gt() %>%
  tab_header(
    title = "S&P 500",
    subtitle = glue::glue("{start_date} to {end_date}")
  ) %>%
  fmt_date(
    columns = vars(date),
    date_style = 3
  ) %>%
  fmt_currency(
    columns = vars(open, high, low, close),
    currency = "USD"
  ) %>%
  fmt_number(
    columns = vars(volume),
    suffixing = TRUE
  )

There are six datasets included in gt: countrypops, sza, gtcars, sp500, pizzaplace, and exibble. All of them are useful for experimenting with the API.

Beyond this simple example, there are many functions available in gt that make it possible to create highly customized tables.

Want to try this out? First and foremost, the gt package is used in an R environment, so, if you don’t have an R installation, it can be obtained from the Comprehensive R Archive Network (CRAN). For the best experience in working with R, use the RStudio Desktop IDE.

You can install the development version of gt from GitHub. Use the following in the R console to install gt.

remotes::install_github("rstudio/gt")

If you encounter a bug, have usage questions, or want to share ideas to make this package better, feel free to file an issue.



Code of Conduct

Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.

License

MIT © RStudio, Inc.

You can’t perform that action at this time.