ggplot
follows a “grammar of graphics” that is a little different from the rest of R’s coding structure- Basic components of a ggplot: a dataset (dataframe), aesthetics (
aes
), geoms, and formattingggplot
takes dataframes as the basic input, not an x vector and y vectorgeom
’s are different types of plot objects that you can add to the plot (e.g. points, lines, bars, etc.)- The
aes
(short for aesthetics) command tells ggplot which variables in the dataset represent the x values, y values, color, size, etc.- You can set aes either in the main
ggplot
call or within ageom
- You can set aes either in the main
- The official ggplot cheatsheet is great! Use this as a quick reference once you get the general idea