Table 1 with gtsummary

Build a publication-ready Table 1 of baseline characteristics in R with gtsummary β€” grouped by treatment, with an automatic test per row. Watch the screencast and copy the code.

The baseline-characteristics table that opens almost every clinical paper β€” in a few lines of R.

Run the code

Everything in the video β€” edit it and press Run Code to run real R right here, or copy it:

Note

The first Run Code installs the packages this lesson needs (gtsummary, dplyr) into your browser session β€” give it 20–40 seconds (gtsummary is large β€” if it is slow in the browser, download the R script and run it locally).

Download this R script  Β·  β–Ά Open the full playground

When to use it. Use it to describe your cohort by group at the start of any analysis. gtsummary picks the right summary (median/IQR or n/%) and the right test for each variable automatically.

Go deeper: the Clinical R Toolkit Β· run it live in the gtsummary demo.

Next: Correlation: Pearson & Spearman β†’