{"id":13423660,"url":"https://github.com/ddsjoberg/gtsummary","last_synced_at":"2025-05-13T21:09:34.688Z","repository":{"id":37319034,"uuid":"172829996","full_name":"ddsjoberg/gtsummary","owner":"ddsjoberg","description":"Presentation-Ready Data Summary and Analytic Result Tables","archived":false,"fork":false,"pushed_at":"2025-05-07T10:41:15.000Z","size":723520,"stargazers_count":1109,"open_issues_count":56,"forks_count":133,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-05-07T10:47:03.711Z","etag":null,"topics":["easy-to-use","gt","html5","r","r-package","regression-models","reproducibility","reproducible-research","rstats","statistics","summary-statistics","summary-tables","table1","tableone"],"latest_commit_sha":null,"homepage":"http://www.danieldsjoberg.com/gtsummary","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddsjoberg.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-02-27T02:44:33.000Z","updated_at":"2025-05-07T02:59:59.000Z","dependencies_parsed_at":"2023-02-09T18:46:11.810Z","dependency_job_id":"ad43eb4b-727f-4d3f-8401-bdbf832156df","html_url":"https://github.com/ddsjoberg/gtsummary","commit_stats":{"total_commits":1760,"total_committers":42,"mean_commits":"41.904761904761905","dds":0.2846590909090909,"last_synced_commit":"d2028dfbf4eb1b5c6192e86d76a8f9b2f4dfda4c"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddsjoberg%2Fgtsummary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddsjoberg%2Fgtsummary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddsjoberg%2Fgtsummary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddsjoberg%2Fgtsummary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddsjoberg","download_url":"https://codeload.github.com/ddsjoberg/gtsummary/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254029000,"owners_count":22002283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["easy-to-use","gt","html5","r","r-package","regression-models","reproducibility","reproducible-research","rstats","statistics","summary-statistics","summary-tables","table1","tableone"],"created_at":"2024-07-31T00:00:40.062Z","updated_at":"2025-05-13T21:09:29.664Z","avatar_url":"https://github.com/ddsjoberg.png","language":"R","funding_links":[],"categories":["C++","UI Components","R"],"sub_categories":["Table"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  warning = FALSE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/ddsjoberg/gtsummary/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ddsjoberg/gtsummary/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/gtsummary)](https://cran.r-project.org/package=gtsummary)\n[![Codecov test coverage](https://codecov.io/gh/ddsjoberg/gtsummary/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ddsjoberg/gtsummary?branch=main)\n[![](https://cranlogs.r-pkg.org/badges/gtsummary)](https://cran.r-project.org/package=gtsummary)\n[![DOI:10.32614/RJ-2021-053](https://zenodo.org/badge/DOI/10.32614/RJ-2021-053.svg)](https://doi.org/10.32614/RJ-2021-053)\n\u003c!-- badges: end --\u003e\n\n## gtsummary \u003ca href='https://github.com/ddsjoberg/gtsummary'\u003e\u003cimg src='man/figures/logo.png' align=\"right\" height=\"120\" /\u003e\u003c/a\u003e\n\nThe {gtsummary} package provides an elegant and flexible way to create publication-ready analytical and summary tables using the **R** programming language.  The {gtsummary} package summarizes data sets, regression models, and more, using sensible defaults with highly customizable capabilities.\n\n* [**Summarize data frames or tibbles**](https://www.danieldsjoberg.com/gtsummary/articles/tbl_summary.html) easily in **R**. Perfect for presenting descriptive statistics, comparing group **demographics** (e.g creating a **Table 1** for medical journals),  and more. Automatically detects continuous, categorical, and dichotomous variables in your data set, calculates appropriate descriptive statistics, and also includes amount of missingness in each variable.\n\n* [**Summarize regression models**](https://www.danieldsjoberg.com/gtsummary/articles/tbl_regression.html) in R and include reference rows for categorical variables. Common regression models, such as logistic regression and Cox proportional hazards regression, are automatically identified and the tables are pre-filled with appropriate column headers (i.e. Odds Ratio and Hazard Ratio). \n\n* [**Customize gtsummary tables**](https://www.danieldsjoberg.com/gtsummary/reference/index.html#section-general-formatting-styling-functions) using a growing list of formatting/styling functions. **[Bold](https://www.danieldsjoberg.com/gtsummary/reference/bold_italicize_labels_levels.html)** labels, **[italicize](https://www.danieldsjoberg.com/gtsummary/reference/bold_italicize_labels_levels.html)** levels, **[add p-value](https://www.danieldsjoberg.com/gtsummary/reference/add_p.html)** to summary tables, **[style](https://www.danieldsjoberg.com/gtsummary/reference/style_percent.html)** the statistics however you choose, **[merge](https://www.danieldsjoberg.com/gtsummary/reference/tbl_merge.html)** or **[stack](https://www.danieldsjoberg.com/gtsummary/reference/tbl_stack.html)** tables to present results side by side... there are so many possibilities to create the table of your dreams! \n\n* **[Report statistics inline](https://www.danieldsjoberg.com/gtsummary/articles/inline_text.html)** from summary tables and regression summary tables in **R markdown**. Make your reports completely reproducible!\n\n\n\nBy leveraging [{broom}](https://broom.tidymodels.org/), [{gt}](https://gt.rstudio.com/), and [{labelled}](http://larmarange.github.io/labelled/) packages, {gtsummary} creates beautifully formatted, ready-to-share summary and result tables in a single line of R code!  \n\nCheck out the examples below, review the [vignettes](https://www.danieldsjoberg.com/gtsummary/articles/) for a detailed exploration of the output options, and view the [gallery](https://www.danieldsjoberg.com/gtsummary/articles/gallery.html) for various customization examples.\n\n\n## Installation\n\nThe {gtsummary} package was written as a companion to the [{gt}](https://gt.rstudio.com/) package from RStudio.\nYou can install {gtsummary} with the following code.  \n\n``` r\ninstall.packages(\"gtsummary\")\n```\n\nInstall the development version with `pak::pkg_install(\"ddsjoberg/gtsummary\", dependencies = TRUE)`\n\n## Examples\n\n### Summary Table\n\nUse [`tbl_summary()`](https://www.danieldsjoberg.com/gtsummary/reference/tbl_summary.html) to summarize a data frame.\n\n\u003cimg src = \"https://github.com/ddsjoberg/gtsummary/raw/main/data-raw/misc_files/tbl_summary_demo1.gif\" alt = \"animated\" width = \"100%\"\u003e\n\nExample basic table:\n\n```{r table1, include = TRUE}\nlibrary(gtsummary)\n\n# summarize the data with our package\ntable1 \u003c-\n  trial |\u003e \n  tbl_summary(include = c(age, grade, response))\n```\n\n```{r tbl_summary_print_simple, include = FALSE}\n# Had to manually save images in temp file, not sure if better way.\ngt::gtsave(as_gt(table1), file = \"man/figures/README-tbl_summary_print_simple-1.png\")\n```\n\n```{r out.width = \"25%\", echo = FALSE}\nknitr::include_graphics(\"man/figures/README-tbl_summary_print_simple-1.png\")\n```\n\n\nThere are many **customization options** to **add information** (like comparing groups) and **format results** (like bold labels) in your table. See the [`tbl_summary()`](https://www.danieldsjoberg.com/gtsummary/articles/tbl_summary.html) tutorial for many more options, or below for one example. \n\n```{r table2, include = TRUE}\ntable2 \u003c-\n  tbl_summary(\n    trial,\n    include = c(age, grade, response),\n    by = trt, # split table by group\n    missing = \"no\" # don't list missing data separately\n  ) |\u003e \n  add_n() |\u003e # add column with total number of non-missing observations\n  add_p() |\u003e # test for a difference between groups\n  modify_header(label = \"**Variable**\") |\u003e # update the column header\n  bold_labels()\n```\n\n```{r tbl_summary_print_extra, include = FALSE}\ngt::gtsave(as_gt(table2), file = \"man/figures/README-tbl_summary_print_extra-1.png\")\n```\n\n\n```{r out.width = \"55%\", echo = FALSE}\nknitr::include_graphics(\"man/figures/README-tbl_summary_print_extra-1.png\")\n```\n\n### Regression Models\n\nUse [`tbl_regression()`](https://www.danieldsjoberg.com/gtsummary/reference/tbl_regression.html) to easily and beautifully display regression model results in a table. See the [tutorial](https://www.danieldsjoberg.com/gtsummary/articles/tbl_regression.html) for customization options.\n\n```{r regress, include = TRUE}\nmod1 \u003c- glm(response ~ trt + age + grade, trial, family = binomial)\n\nt1 \u003c- tbl_regression(mod1, exponentiate = TRUE)\n```\n\n```{r tbl_regression_printa, include = FALSE}\ngt::gtsave(as_gt(t1), file = \"man/figures/README-tbl_regression_printa-1.png\")\n```\n\n\n```{r out.width = \"40%\", echo = FALSE}\nknitr::include_graphics(\"man/figures/README-tbl_regression_printa-1.png\")\n```\n\n### Side-by-side Regression Models\n\nYou can also present side-by-side regression model results using `tbl_merge()`\n\n```{r}\nlibrary(survival)\n\n# build survival model table\nt2 \u003c-\n  coxph(Surv(ttdeath, death) ~ trt + grade + age, trial) |\u003e \n  tbl_regression(exponentiate = TRUE)\n\n# merge tables\ntbl_merge_ex1 \u003c-\n  tbl_merge(\n    tbls = list(t1, t2),\n    tab_spanner = c(\"**Tumor Response**\", \"**Time to Death**\")\n  )\n```\n\n```{r tbl_merge_ex1, include = FALSE}\ngt::gtsave(as_gt(tbl_merge_ex1), file = \"man/figures/README-tbl_merge_ex1-1.png\")\n```\n\n\n```{r out.width = \"60%\", echo = FALSE}\nknitr::include_graphics(\"man/figures/README-tbl_merge_ex1-1.png\")\n```\n\nReview even more output options in the **[table gallery](https://www.danieldsjoberg.com/gtsummary/articles/gallery.html)**.\n\n## gtsummary + R Markdown\n\nThe **{gtsummary}** package was written to be a companion to the **{gt}** package from RStudio.\nBut not all output types are supported by the **{gt}** package.\nTherefore, we have made it possible to print **{gtsummary}** tables with various engines.\n\nReview the **[gtsummary + R Markdown](https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html)** vignette for details.\n\n\u003ca href=\"https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html\"\u003e\n```{r out.width = \"55%\", echo = FALSE}\nknitr::include_graphics(\"man/figures/gt_output_formats.PNG\")\n```\n\u003c/a\u003e\n\n## Save Individual Tables\n\n{gtsummary} tables can also be saved directly to file as an image, HTML, Word, RTF, and LaTeX file.\n\n```r\ntbl |\u003e \n  as_gt() |\u003e \n  gt::gtsave(filename = \".\") # use extensions .png, .html, .docx, .rtf, .tex, .ltx\n```\n\n## Additional Resources\n\n- The best resources are the gtsummary vignettes: [table gallery](https://www.danieldsjoberg.com/gtsummary/articles/gallery.html), [`tbl_summary()` tutorial](https://www.danieldsjoberg.com/gtsummary/articles/tbl_summary.html), [`tbl_regression()` tutorial](https://www.danieldsjoberg.com/gtsummary/articles/tbl_regression.html), [`inline_text()` tutorial](https://www.danieldsjoberg.com/gtsummary/articles/inline_text.html), [gtsummary themes](https://www.danieldsjoberg.com/gtsummary/articles/themes.html), [gtsummary+R markdown](https://www.danieldsjoberg.com/gtsummary/articles/rmarkdown.html).\n- The R Journal Article [*Reproducible Summary Tables with the gtsummary Package*](https://github.com/ddsjoberg/gtsummary/raw/main/data-raw/RJ-2021-053.pdf).\n- The [RStudio Education Blog](https://education.rstudio.com/blog/2020/07/gtsummary/) includes a post with a brief introduction to the package. \n- A [recording of a presentation](https://www.youtube.com/watch?v=tANo9E1SYJE) given to the Weill Cornell Biostatistics Department and the Memorial Sloan Kettering R Users Group.\n\n    \u003ciframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/tANo9E1SYJE\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\u003c/iframe\u003e\n\n## Cite gtsummary\n\n```{text, comment=\"\", eval = FALSE}\n\u003e citation(\"gtsummary\")\n\nTo cite gtsummary in publications use:\n\n  Sjoberg DD, Whiting K, Curry M, Lavery JA, Larmarange J. Reproducible summary tables with the gtsummary package.\n  The R Journal 2021;13:570–80. https://doi.org/10.32614/RJ-2021-053.\n\nA BibTeX entry for LaTeX users is\n\n  @Article{gtsummary,\n    author = {Daniel D. Sjoberg and Karissa Whiting and Michael Curry and Jessica A. Lavery and Joseph Larmarange},\n    title = {Reproducible Summary Tables with the gtsummary Package},\n    journal = {{The R Journal}},\n    year = {2021},\n    url = {https://doi.org/10.32614/RJ-2021-053},\n    doi = {10.32614/RJ-2021-053},\n    volume = {13},\n    issue = {1},\n    pages = {570-580},\n  }\n```\n\n## Contributing\n\nBig thank you to `@jeffreybears` for the hex sticker!\n\nPlease note that the {gtsummary} project is released with a [Contributor Code of Conduct](https://www.danieldsjoberg.com/gtsummary/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. Thank you to all contributors!  \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddsjoberg%2Fgtsummary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddsjoberg%2Fgtsummary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddsjoberg%2Fgtsummary/lists"}