R in 3 Months Week 3 (Data Visualization)

What is the most confusing thing about ggplot?

Please put your answer in the chat!

Agenda

  1. Housekeeping

  2. ggplot

  3. Data viz questions

  4. Data viz exercise

  5. Next week

Housekeeping

Housekeeping

  • Videos for from second half of course are being added this week

  • RStudio

  • Live session during catch-up week (April 9) on using AI with R. Email us your questions!

ggplot

Data Viz Questions

== and lowercase x and y

penguins |>
  filter(species == "Gentoo")
ggplot(
  data = penguins, # why can't I use == within this function?
  mapping = aes(
    x = flipper_length_mm, # must be lowercase x and y
    y = body_mass_g
  )
) +
  geom_point()

Color vs fill

Why is it that the color= option is treated differently by geom_point and geom_col? The logic seems inconsistent here since color= is used as if it is fill= by geom_point. What if I want the scatter plot to have black dots with outline color different by island?

Is there a “correct” order to put geoms, scales, themes, etc?

Width of bars in bar charts

Reordering bar charts

Wrapping long text in charts

Data Viz Exercise

Data Viz Exercise

Next Week

You’ll be learning about Quarto!

  • Course assignment: learn the basics of Quarto

  • Project assignment: take what you’ve done so far and turn it into a Quarto document