| Hosted by CoCalc | Download
---
title: "References in R Markdown" author: "Harald Schilly" date: "`r Sys.Date()`" site: "bookdown::bookdown_site" output: bookdown::html_document2: default
---

Introduction

Using RMarkdown's bookdown rendering, long documents with LaTeX-style references can be rendered. More information here: bookdown: Authoring Books and Technical Documents with R Markdown

E=mc2(#eq:emc2)\begin{equation} E = m c^2 (\#eq:emc2) \end{equation}

Examples

Example 1

Let's start with a simple Formula:

f(k)=(nk)pk(1p)nk(#eq:binom)\begin{equation} f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k} (\#eq:binom) \end{equation}

The equation @ref(eq:binom) is well known.

Example 2

Another well known formula is the following:

For a right triangle, if $c$ denotes the length of the hypotenuse and $a$ and $b$ denote the lengths of the other two sides, we have \begin{equation} a^2 + b^2 = c^2 (\#eq:pyth) \end{equation}

Which is this equation:

Fill up

A normal paragraph.

(ref:foo) A scatterplot of the data cars using base R graphics.

plot(cars) # a scatterplot

More text ...

More text ...

Python code

library(reticulate) use_python("/usr/bin/python3")
import numpy as np import pandas as pd x = np.random.randn(1000) pd.Series(x).describe()

Plotting with Python

import seaborn seaborn.set('paper') import numpy as np import matplotlib.pyplot as plt xx = np.linspace(0, 10, 100) yy = np.exp(0.1 * -xx) * np.sin(2 * xx) plt.plot(xx, yy) plt.grid(True) plt.show()

More text ...

More text ...

More text ...

More text ...

More text ...

More text ...

More text ...

More text ...

More text ...

More text ...

More text ...

Testing reference links

First check if you know about theorem @ref(thm:pyth) with the formula @ref(eq:pyth), that famous equation @ref(eq:emc2) and then look up what @ref(eq:binom) is about!

... and don't forget the figure @ref(fig:foo)!

More information