Useful hints for a newbie on Rmarkdown

An R Markdown newbie walks on eggshells so as to not look naïve.  But the community is so nice to them, and since the help is all in the open, it reaches many more.  So here are a few items I learned beyond the usual R Markdown and the ubiquitous example about plotting something about cars.

Not Autonumbering

Don’t want to autonumber. If you write (1) First, it will automatically start numbering it. Convenient, but I do not like it sometimes. So how does one stop items from autonumbering. Just put a period sign after (1), that is, (1).  Here is an example.  This will keep the numbering the same as what is inputted.

(1).first
(2).second
(2).second
(3).numbering went away
Not wanting to center a block equation

Do you not want a block equation (an equation on its own separate line as opposed to being part of the text which is called an inline equation) to not be in the center, but wanted it tabbed instead.  It is easy to center equations by writing them within two double dollars symbols, that is, $$   $$.  But I do not like centering.  I like my block equations tabbed.

The equation
$latex a_{11} x_1+a_{12} x_2+\cdots+a_{1n}x_n=b_1$
gets centered by entering as

$$a_{11} x_1+a_{12} x_2+\cdots+a_{1n}x_n=b_1$$

The following, however, put tabs in the equation. Each &emsp puts 4 spaces.  Note also the two dollar symbols, that is, $    $, bounding the equation

  $a_{11} x_1+a_{12} x_2+\cdots+a_{1n}x_n=b_1$
Defining often used equations

If you are using certain equation parts, again and again, you can define them.  See  here we are defining $latex \overline{X}$ and $latex \sum_{i=1}^{n}$

```{=tex}
\def\Xbar{\overline{X}}
\def\sumn{\sum_{i=1}^{n}}
```
Aligning equations to a character

Many times, you may have equations that are aligned by a character, say an equal to sign.  But if the equations get centered, the equal to sign may not get centered.  This is simply done by adding a & before the aligned character in all lines.  For example, if you want to show the following,

you would enter it as the following.  Note where the & is.

$\begin{align} 
\ S &= \int_{3}^{9}{x^2 dx}\\ 
&= \left[\frac{x^3}{3}\right]_3^9\\ 
&= \frac{9^3}{3}-\frac{9^3}{3}\\ 
&= 234 \end{align}$

____________________________

References: An Example R Markdown http://statpower.net/Content/311/R%20Stuff/SampleMarkdown.html

This post is brought to you by

2 thoughts on “Useful hints for a newbie on Rmarkdown”

Leave a Reply