Graphics Reference
In-Depth Information
Figure 7-5. Annotation with mathematical expressions
Discussion
Mathematical expressions made with text geoms using parse=TRUE in ggplot2 have a format
similar to those made with plotmath and expression in base R, except that they are stored as
strings, rather than as expression objects.
To mix regular text with expressions, use single quotes within double quotes (or vice versa) to
mark the plain-text parts. Each block of text enclosed by the inner quotes is treated as a variable
in a mathematical expression. Bear in mind that, in R's syntax for mathematical expressions, you
can't simply put a variable right next to another without something else in between. To display
two variables next to each other, as in Figure 7-6 , put a * operator between them; when displayed
in a graphic, this is treated as an invisible multiplication sign (for a visible multiplication sign,
use %*% ):
Search WWH ::




Custom Search