2.3 Quarto tables, figures, and stats
Open the slides in a new tab here.
Exercises
Return to your quarto document with the tables.
- Create a new chunk with a
tbl_summary()table that has at least thesleep_wkndvariable 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. - 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.
- 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. - Now, store that value as an object in the chunk instead of printing it. Add it as inline text.
- Calculate the statistic directly as inline text from the table you created.
- Reformat that inline text from the table so that it only prints the median, not the IQR.
- Change the means to medians in your table and re-render.