Math inside RMarkdown

You may want to include math like greek symbols, etc., in your R Markdown documents. In this class, this is totally optional. If you want a \(\mu\) in your document, you can just type “mu” instead and forget about the extra complication. However, this document describes how to put math into your write up in case you want to. It will definitely look nicer that way :)

In a text chunk, you can use mathematical notation if you surround it by dollar signs $ for inline mathematics and $$ for displayed equations. Do not leave a space between the $ and your mathematical notation. The mathematical typesetting is based on LaTeX, so if you need to search for the way to make a particular symbol, include latex in your search.

In LaTeX, curly braces ({ and }) are used to surround items that are to be considered as one object from LaTeX’s perspective.
Without them, usually the next letter or digit will be used, but that isn’t usually what you want. For example $\mu^null$ produces \(\mu^null\), but $\mu^{null}$ produces \(\mu^{null}\).

Mathematical Notation

Here are some common mathematical things you might use in statistics

\(x = y\) $x = y $
\(x < y\) $x < y $
\(x > y\) $x > y $
\(x \le y\) $x \leq y $
\(x \ge y\) $x \geq y $
\(x \neq y\) $x \neq y $
\(x^{n}\) $x^{n}$
\(x_{n}\) $x_{n}$
\(\bar{x}\) $\bar{x}$
\(\hat{x}\) $\hat{x}$
\(\frac{a}{b}\) $\frac{a}{b}$
\(X \sim \text{Normal}(\mu, \sigma)\) $X \sim \text{Normal}(\mu, \sigma)$

Greek Letters

\(\alpha A\) $\alpha A$ \(\nu N\) $\nu N$
\(\beta B\) $\beta B$ \(\xi\Xi\) $\xi\Xi$
\(\gamma \Gamma\) $\gamma \Gamma$ \(o O\) $o O$ (omicron)
\(\delta \Delta\) $\delta \Delta$ \(\pi \Pi\) $\pi \Pi$
\(\epsilon \varepsilon E\) $\epsilon \varepsilon E$ \(\rho\varrho P\) $\rho\varrho P$
\(\zeta Z\) $\zeta Z \sigma \,\!$ \(\sigma \Sigma\) $\sigma \Sigma$
\(\eta H\) $\eta H$ \(\tau T\) $\tau T$
\(\theta \vartheta \Theta\) $\theta \vartheta \Theta$ \(\upsilon \Upsilon\) $\upsilon \Upsilon$
\(\iota I\) $\iota I$ \(\phi \varphi \Phi\) $\phi \varphi \Phi$
\(\kappa K\) $\kappa K$ \(\chi X\) $\chi X$
\(\lambda \Lambda\) $\lambda \Lambda$ \(\psi \Psi\) $\psi \Psi$
\(\mu M\) $\mu M$ \(\omega \Omega\) $\omega \Omega$

Source

This document is adapted from Randall Pruim’s version here: https://www.calvin.edu/~rpruim/courses/s341/S17/from-class/MathinRmd.html