1.6 Descriptive tables with {gtsummary}

Slides

Open the slides in a new tab here.

Exercises

  1. Download the R script here and put it into your in-class project folder.
  2. Install {gtsummary} and run the examples.
  3. Make a tbl_summary(). Include categorical region, race/ethnicity, income, and the sleep variables (use a helper function to select those) and make sure they are nicely labeled.
  4. Stratify the table by sex. Add a p-value comparing the sexes and an overall column combining both sexes.
  5. For the income variable, show the 10th and 90th percentiles of income with 3 digits, and for the sleep variables, show the min and the max with 1 digit.
  6. Add a footnote to the race/ethnicity variable with a link to the page describing how NLSY classified participants: https://www.nlsinfo.org/content/cohorts/nlsy79/topical-guide/household/race-ethnicity-immigration-data
  7. Play around with the extra functions from the examples and/or from the documentation

Resources