Lab-2: Data wrangling

Lab-Lecture

Dr. Elijah Meyer

Duke University
STA 199 - Spring 2023

January 31, 2023

Checklist

– Go to the course GitHub org and find your lab-02 (repo name will be suffixed with your GitHub name).

– Clone the repo in your container, open the Quarto document in the repo

Announcements

– HW-1 due tonight (11:59) - Gradescope

– Labs due Fri (11:59) - Gradescope

– Do not forget to select pages!!

Inline text Demo

– How to seamlessly add code output to bodies of text

Example

– Inline R code is embedded in the narratives of the document (outside the code chunk) using the syntax:

– In the rendered document, code in the syntax will display the output.

Why this matters

– Efficiency

– Reproducibility

Common Mistakes

– Forgetting the tick marks

– Forgetting the r

Check your document to make sure the code produces what you think

group_by

group_by

– group_by() takes an existing tbl and converts it into a grouped tbl where operations are performed “by group”

– often used with summarize()

group_by