Chapter5 Problem 5

Using the heightweight dataset in the gcookbook package, replicate the plot below using the following settings:

  • Set size = 3 of points
  • Set alpha = 0.5
  • Use theme_classic()

Answer

library(gcookbook)

ggplot(heightweight, aes(x = heightIn, y = weightLb, color = sex)) +
  geom_point(alpha = 0.5, size=3) +
  geom_smooth(method = "lm", se=FALSE) +
  labs(title = "Scatterplot", 
       subtitle = "Weight Vs Height", 
       caption = "source: heightweight"
  ) + 
  theme_classic()
## `geom_smooth()` using formula 'y ~ x'