Update this template with your custom content.
While drafting this document, you may want to preview a formatted version. The easiest way to do that is to open this file in RStudio and click the Knit
button in the top toolbar.
This document is written in R Markdown.
Some common markdown syntax is demonstrated below. More information is available from RStudio, among many other places.
Text can easily be made italic or bold or ~~strikethrough~~ or ~subscript~ or ^superscript^.
You can make unordered lists:
You can also make ordered lists:
Save image files in a subfolder called images/
in the same location as this file. Insert them into the document like this:

Equations can be easily inserted with standard LaTeX syntax. Inline: $y_i = \beta_0 + \beta_1x_i + \varepsilon_i$
Standalone:
$$y_i = \beta_0 + \beta_1x_i + \varepsilon_i$$
Insert a footnote anywhere.[^my-note]
[^my-note]: Citations and footnotes will be formatted automatically when you render the document.
To add citations at the end of this article, you need to do three things:
references.bib
and populate it with your list of sources.# bibliography: "references.bib"
line in the header of this file. (In other words, delete the #
at the beginning of the file.) Create a new file called "references.bib" in the same folder as this article. Add your references to that that file in BibTeX format.
Here's an example of BibTeX format:
@article{Cohen1992, doi = {10.1037/0033-2909.112.1.155}, url = {https://doi.org/10.1037/0033-2909.112.1.155}, year = {1992}, publisher = {American Psychological Association ({APA})}, volume = {112}, number = {1}, pages = {155--159}, author = {Jacob Cohen}, title = {A power primer.}, journal = {Psychological Bulletin} }
Many reference managers will allow you to copy or export BibTeX versions of saved references. For example:
www.doi2bib is a useful website that will generate a formatted BibTeX entry from a DOI.
Every BibTeX entry in references.bib should start with a unique ID (e.g., Cohen1992
). To reference a book or article in this article, insert its unique ID with an @
symbol in front. For example, I could add a reference to the Cohen article by inserting [@Cohen1992]
into this paragraph.
You need to include the line bibliography: "references.bib"
in the YAML header of this file so the knit function can find the file. Delete the #
sign to change the line from a comment into an active argument.
Embed R code and results via code chunks. You can decide whether to print the code, the results, and any messages or warnings.
mean_speed <- mean(cars$speed) mean_speed
Objects in the current environment are accessible via inline code. For example, the mean speed of the cars
dataset is r mean_speed
.
If you want to print the code verbatim without running it, you can do that by adjusting the chunk options:
min_speed <- min(cars$speed) min_speed
And if you want to run code without printing it, you can do that too.
max_speed <- max(cars$speed) max_speed
The maximum speed is r max_speed
.
Print a formatted table with knitr::kable()
and refer to it as Table \@ref(tab:cars-table):
knitr::kable( head(cars), caption = "A table with some car data." #,longtable = TRUE )
Tip: to allow tables to break across PDF pages, pass kable(..., longtable = TRUE)
.
Generate a plot and refer to it as Figure \@ref(fig:cars-figure):
plot(cars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.