- Notifications
You must be signed in to change notification settings - Fork218
Easily generate information-rich, publication-quality tables from R
License
Unknown, MIT licenses found
Licenses found
rstudio/gt
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
With thegt package, anyone can make wonderful-looking tables usingtheR programming language. Thegt philosophy: we can constructa wide variety of useful tables with a cohesive set of table parts.These include thetable header, thestub, thecolumn labels andspanner column labels, thetable body, and thetable footer.
It all begins with preprocessedtable data (be it a tibble or a dataframe). You then decide how to compose yourgt table with theelements and formatting you need for the task at hand. Finally, thetable is rendered by printing it at the console, including it in an RMarkdown document, or exporting to a file usinggtsave(). Currently,gt supportsHTML output, withLaTeX andRTF planned forthe future.
Thegt package is designed to be both straightforward yet powerful.The emphasis is on simple functions for the everyday display tableneeds. Here is a brief example of how to usegt to create a tablefrom the includedsp500 dataset:
library(gt)library(tidyverse)library(glue)# Define the start and end dates for the data rangestart_date<-"2010-06-07"end_date<-"2010-06-14"# Create a gt table based on preprocessed# `sp500` table datasp500 %>% filter(date>=start_date&date<=end_date) %>% select(-adj_close) %>% gt() %>% tab_header(title="S&P 500",subtitle=glue::glue("{start_date} to {end_date}") ) %>% fmt_date(columns=date,date_style=3 ) %>% fmt_currency(columns= c(open,high,low,close),currency="USD" ) %>% fmt_number(columns=volume,suffixing=TRUE )
There are six datasets included ingt:countrypops,sza,gtcars,sp500,pizzaplace, andexibble. All of them are usefulfor experimenting withgt’s functions.
Beyond this simple example, there are many functions available ingtfor creating super-customized tables.
Want to try this out? Then, take thegt Test Drive onRStudioCloud. It’s full of ready-to-run examples.
Thegt package can be installed fromCRAN with:
install.packages("gt")You can also choose to install the development version ofgt fromGitHub:
devtools::install_github("rstudio/gt")
If you encounter a bug, have usage questions, or want to share ideas tomake this package better, please feel free to file anissue.
Thegt package joins a burgeoning collection of packages for displaytable generation. Why another? We feel that there is enough room in thisspace to innovate further. Here are some of the ways thatgtcontributes to this ecosystem:
- the interface is high-level and declarative (general instructionsversus very specific)
- the formatting options are ‘batteries included’ (scientificnotation, uncertainty, ranges, percentages, suffixes, localizedcurrency, dates/times + much more)
- there is excellent, pain-free support for footnotes
- the output is ‘camera-ready’
- it will eventually support multiple output formats (including LaTeX)with the same declarative interface
- the API closely follows tidyverse conventions by adhering to thetidyverse style guide
- a focus on making the package documentation and examples the bestthey can be
- rigorous QA/QC measures: high test coverage for automated tests, andthorough manual testing by QA engineers (with every proposed codechange)
Whilegt is trying to do something different with its own interface,it may not suit your specific needs. Here is a listing of other leadingtable-makingR packages, with links to their respective projectpages:
- knitr (GITHUB, WEBSITE)
- kableExtra (GITHUB, WEBSITE)
- formattable (GITHUB, WEBSITE)
- DT (GITHUB, WEBSITE)
- pander (GITHUB, WEBSITE)
- huxtable (GITHUB, WEBSITE)
- reactable (GITHUB, WEBSITE)
- flextable (GITHUB, WEBSITE)
- ftextra (GITHUB, WEBSITE)
- pixiedust (GITHUB)
- tangram (GITHUB)
- ztable (GITHUB)
- condformat (GITHUB)
- stargazer (CRAN)
- xtable (CRAN)
Please note that the gt project is released with acontributorcode ofconduct.
Byparticipating in this project you agree to abide by its terms.
gt is licensed under the MIT license. See theLICENSE.md file for more details.
© RStudio, PBC.
About
Easily generate information-rich, publication-quality tables from R
Topics
Resources
License
Unknown, MIT licenses found
Licenses found
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
