less than 1 minute read

Graphs in R

Principles of analytical graphs:

  1. Show comparisons
  2. Show causality, mechanism, explanation
  3. Show multivariate data
  4. Integrate multiple modes of evidence
  5. Describe and document the evidence
  6. Content is king

From the JHU course: R has 3 common ways of plotting graphs. Base, lattice and ggplot2. The base plotting library follows the idea of building up a plot by starting from a clean canvas and then annotating it with labels/titles/lines/legends etc. Lattice involves making the plot in a single function call. ggplot2 follows the grammar of graphics and is midway between lattice and base. You can incrementally add aesthetics to your plots.

Graphic devices in R are basically the locations where you send your plot like a window is a device, a pdf, png or svg file is a device etc. You can have multiple devices and jump/copy between them with device.set(), device.cur() and device.copy().