Lecture 4
Duke University
STA 199 - Fall 2023
2023-09-07
– Are you in the GitHub organization?
– Go to our GitHub. This link is also at the bottom of our slides. Make sure you log into Git to see your repos!
– Do you see hw-01 & ae-03? If not, this is your final warning to come talk with us!
– Here is a public repo for today if needed: ae-03
Do not click and clone the public repo if you have a personalized repo. This is the last class we will have a public repo.
– Keeping up with the Prepare link on course website
– Try cloning AE-03! We will also do this together as a class.
– More Plots!
– More practice with R
HW-1 is out now; due September 12th at 11:59 on Gradescope.
– Mark all the pages associated with exercise
– Do not select any pages of your PDF submission to be associated with the “Workflow & formatting” question.
– AEs will be checked for “completion” next week
– All due on Friday at 11:59 pm
– Answer keys will be posted shortly after
R update should be coming soon
Practice reading the following code as a sentence
mtcars
: The data was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models).
mtcars |>
ggplot(
aes(
x = mpg, y = wt)
)
+geom_point()
Based on the style guide, how can the code below be improved?
iris |>
filter(Species == "setosa") |>
ggplot(aes(x = Sepal.Width, y = Sepal.Length))+ geom_point()
– + should always have a space before it, and should be followed by a new line
iris |>
filter(Species == "setosa") |>
ggplot(aes(x = Sepal.Width, y = Sepal.Length)) +
geom_point()
– Construct plots with ggplot()
.
– Layers of ggplots are separated by +
s.
– 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.