Exercises

ggplot(mpg, aes(x = cty, y = hwy)) + 
  geom_point()

  • directly correlated
  • issues
  • discrete measurements
  • overplotting
  • scale
ggplot(mpg, aes(model, manufacturer)) + geom_point()

  • This plot maps model (specific car models) to the x-axis and manufacturer to the y-axis. Each point represents one observation in the dataset.

  • usefulness

  • both variables are categorical

  • no natural order

  • cluttered

  • informative

  • aggregate

  • reorder

  • facet

ggplot(mpg, aes(cty, hwy)) + geom_point()

ggplot(diamonds, aes(carat, price)) + geom_point()

ggplot(economics, aes(date, unemploy)) + geom_line()

ggplot(mpg, aes(cty)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.