2.3 Quarto tables, figures, and stats

Open the slides in a new tab here.

Exercises

Return to your quarto document with the tables.

  1. Create a new chunk with a tbl_summary() table that has at least the sleep_wknd variable in the overall data. You can add other ariables, and you can stratify by a variable as long as you add an overall column as well. Then add a label and caption to the chunk.
  2. Write a sentence somewhere outside of the table chunk that cross-references it (e.g., Table 1 shows the descriptive statistics about sleep). Then add labels to the other tables in your document, re-render and watch the numbering change.
  3. Add a chunk where you calculate median number of hours of sleep on weekends overall in the data (you can use the median(., na.rm = TRUE) function). Make sure your code prints that output when it renders.
  4. Now, store that value as an object in the chunk instead of printing it. Add it as inline text.
  5. Calculate the statistic directly as inline text from the table you created.
  6. Reformat that inline text from the table so that it only prints the median, not the IQR.
  7. Change the means to medians in your table and re-render.

Resources