Math symbols in R charts: a cheat sheet

April 15, 2013
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

If you're creating a scientific graphic in the R language, there's a good chance you'll be wanting to include some mathematical symbols somewhere on the chart. You might want to use a symbol like μ as an axis label, annotate a curve with simple math like x2, or even put a complete equation like:

 Sumx

in the title. You can do this easily in R using the plotmath syntax. Using escape sequences reminiscent of LaTeX, you can include beautifully-formatted mathematical symbols and equations in charts wherever you can place text. For example, the summation above can be added to a plot with an R statement like text(2,5,expression(sum(x[i], i=1, n)). This cheat sheet on mathematical annotation in R provides a guide to commonly-used symbols and equations, including:

Plotmath
The cheat sheet comes courtesy of Vistat, a site that provides working recipes for statistical graphics. R programmers should also check out this cheat sheet for plotting symbols and colors for R graphics.

Vistat: Mathematical Notation in R (via Yihui Xie)

To leave a comment for the author, please follow the link and comment on his blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.