Chapter 3 Mathematical Notation in R

This is a guide for how to make math symbols in RMarkdown.

3.1 Making Greek Letters

To make a Greek letter in R, You just use \ and then the name of the letter.

  • Example: $\beta$, $\gamma$, $\epsilon$

If you want a subscript, like \(\beta_1\), you use $\beta_1$.

If you want a subscript that is multiple letters (like \(R^2_{adj}\)), you use $R^2_{adj}$

3.2 Make an Equation

You put a $ at the beginning of the equation and $ at the end.

  • Example: $Y = \beta_0 + \beta_1X + \epsilon$.

If you want the equation on its own line, use two $ at the beginning and end.

3.3 Make a Fraction

You use the command \frac{ }{ }.

Whatever you put in the first { } is in the numerator, and in the second { } is in the denominator,

  • Example: Typing $\frac{1}{2}$ makes one-half
  • Example: Typing $log \left( \frac{ \pi_i }{ 1- \pi_i} \right)$ makes \(log \left( \frac{ \pi_i }{ 1- \pi_i} \right)\)

3.4 Writing a Distribution

To make the ~ symbol in a distribution, use \sim.

  • Example: Typing $Y_i \sim N( \mu, \sigma)$ makes \(Y_i \sim N( \mu, \sigma)\).