[TIL] 18-Mar-2020
Graphs in R
Principles of analytical graphs:
- Show comparisons
- Show causality, mechanism, explanation
- Show multivariate data
- Integrate multiple modes of evidence
- Describe and document the evidence
- 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()
.