Get startedGet started for free

Formatting with Markdown

1. Formatting with Markdown

After this first look at the RMarkdown exercise interface, we are going to focus on the language that gives RMarkdown its name: Markdown.

2. Markdown

Markdown is what computer scientists usually call a Markup language (pun intended). You might know HTML, which is also a markup language. The acronym actually stands for hypertext markup language. However, HTML is tedious to write, that's why John Gruber invented an easier alternative in 2004. Markdown was born. The primary purpose of Markdown was to convert it into HTML so it could be used on websites.

3. Markdown

Let's look at a quick example. With Markdown, you can easily format chunks of text. You can add headers with the hash sign, and these headers can have different levels of importance. One hash sign usually stands for a first-level header, two hash signs for a second-level header, and so forth. You can also convert text into bold with double asterisks, emphasize text with single asterisks or even add links, and much more. Let's compare this to traditional HTML. First of all, HTML needs all formatted elements to be enclosed in so-called tags like h1 or strong, which makes it more tedious to write and probably harder to read. Also, it needs many more characters and is more error-prone than Markdown.

4. Pandoc Markdown

Put simply, RMarkdown is prose formatted with Markdown, and R code. The cool thing about RMarkdown is that it can not only be converted into HTML, but also into PDF and Word documents. RMarkdown actually uses a slightly different dialect of Markdown, so-called Pandoc Markdown. In the first video of this chapter you've seen that, behind the scenes, Pandoc is used to convert a Markdown file to a wide variety of different output formats. If you want to get to know all possible formatting possibilities with Pandoc Markdown – and trust me, there are a lot – have a look at this reference guide.

5. Let's put this into practice!

Okay, let's practice. In the next few exercises you will dive into Markdown prose and explore some of the formatting options you've just seen.