16.1 Getting started

Load package:

library(ggplot2)
  • All ggplots start with a base layer created with the ggplot() function:
ggplot(data=dataframe, mapping=aes(x=column1, y=column2))

The base layer is setting the grounds but NOT plotting anything:

  • You then add a layer (with the + sign) that describes what kind of plot you want:
    • geom_point()
    • geom_bar()
    • geom_histogram()
    • geom_boxplot()
  • And then you will add one layer at a time to add more features to your plot!