The ggplot package is used to create graphical displays of data. All graphs have the same basic syntax.

  • The first line of code below creates a plot with the X and Y variables from a data set called DATA.

  • The second line of code transforms the data provided in the first line oc code into a specific type of PLOT. Examples of specific plots are histograms, bar chars, and scatter plots. See the other help pages listed in the ggplot2 menu for details on specific types of plots.

  • The third and fourth lines of code are used to add more detail to the plot created by the first two lines of code.

ggplot( data = DATA, x = X, y = Y) + 
  geom_PLOT() + 
  coordinatess() +
  facets() 

Mathematicss, Computer Science, and Statistics Department Gustavus Adolphus College