Lecture 3
Dr. Elijah Meyer + Konnie Huang
Duke University
STA 199 - Fall 2022
September 5th, 2022
– Have a GitHub account and have it connected with R (Lab 0)
– Have checked the GitHub username sheet
– Keeping up with the Prepare link on course website
– Go to the course GitHub org and find your ae-02-starwars
(repo name will be suffixed with your GitHub name). – Clone the repo in your container, open the Quarto document in the repo
– Think about what to do (and not to do) with visualizations
– Understand the fundamentals of ggplot
– Build appropriate visualizations
– More practice with R
– Turn in AE’s via GitHub (will go over today)
– Will turn in Lab 1 via GitHub (Thursday)
– Release HW 1 Wednesday (Turned in on Gradescope: Being set up now)
https://app.sli.do/event/g6fnKCDuZ1sw8NKiZTu3Rb
– Sometimes you’ll run the code and nothing happens. Check the left-hand of your console: if it’s a +, it means that R doesn’t think you’ve typed a complete expression and it’s waiting for you to finish it.
Discuss the following for the visualization.
– What is the visualization trying to show?
– What is effective, i.e. what is done well?
– What is ineffective, i.e. what could be improved?
– What are you curious about after looking at the visualization?
04:00
ae-02-starwars
ae-02-starwars
(repo name will be suffixed with your GitHub name).– 1 categorical variable, 1 quantitative variable (often ordinal)
– 2 quantitative variables
– 1 quantitative variable
04:00
– geom_histogram
– geom_point
– geom_bar
– Construct plots with ggplot()
.
– Layers of ggplots are separated by +
s.
– The formula is (almost) always as follows:
– Aesthetic attributes of a geometries (color, size, transparency, etc.) can be mapped to variables in the data or set by the user.
– Use facet_wrap()
when faceting (creating small multiples) by one variable and facet_grid()
when faceting by two variables.