Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/gtPublic

Easily generate information-rich, publication-quality tables from R

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

rstudio/gt

 
 

CRAN statusR build statusCoverage status

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 withtable data (be it a tibble or a data frame). Youthen decide how to compose yourgt table with the elements andformatting you need for the task at hand. Finally, the table is renderedby printing it at the console, including it in an R Markdown document,or exporting to a file usinggtsave(). Currently,gt supports theHTML,LaTeX, andRTF output formats.

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("{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.

RStudio Cloud Example

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.


Howgt fits in with Other Packages that Generate Display Tables

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’
  • multiple output formats are supported with the same declarativeinterface
  • the API closely follows tidyverse conventions by adhering to thetidyverse style guide
  • there’s a focus on making the package documentation and examples thebest they 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:

Code of Conduct

Please note that the gt project is released with acontributor code ofconduct.
Byparticipating in this project you agree to abide by its terms.

📄 License

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

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp