---
title: "Learn R Markdown"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Learn R Markdown}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```



# Overview

<a href="https://r4ds.had.co.nz/"><img src="https://r4ds.had.co.nz/cover.png" alt="R for Data Science" data-external=1 width="250" style="padding: 0 15px; float: right;"/></a>

If you are new to using R Markdown, we encourage you to start with a systematic overview, rather than diving right in to reading documentation pages. The best place to start is the ["Communication" section](https://r4ds.had.co.nz/communicate-intro.html) in the book "R for Data Science" (R4DS for short), an O’Reilly book written by Hadley Wickham and Garrett Grolemund.

Here are the chapters that cover R Markdown, as summarized by Hadley and Garrett:

* In [R Markdown](https://r4ds.had.co.nz/r-markdown.html), you will learn about R Markdown, a tool for integrating
  prose, code, and results. You can use R Markdown in notebook mode for 
  analyst-to-analyst communication, and in report mode for 
  analyst-to-decision-maker communication. Thanks to the power of R Markdown
  formats, you can even use the same document for both purposes.
  
* In [R Markdown formats](https://r4ds.had.co.nz/r-markdown-formats.html), you'll learn a little about the many other varieties
  of outputs you can produce using R Markdown, including dashboards, websites,
  and books.
  
* We'll finish up with [R Markdown workflow](https://r4ds.had.co.nz/r-markdown-workflow.html), where you'll learn about the
  "analysis notebook" and how to systematically record your successes and failures so that you can learn from them.
  
<br>
<br>

<a href="https://rmarkdown.rstudio.com/lesson-1.html"><img src="https://rmarkdown.rstudio.com/lesson-images/params-1-hawaii.png" alt="R Markdown tutorials" data-external=1 width="450" style="padding: 0 15px; float: right;"/></a>

# Tutorials

The [R Markdown website](https://rmarkdown.rstudio.com/lesson-1.html) offers a series of tutorials you can follow to see what is possible with R Markdown. 

These tutorials offer accompanying [RStudio Cloud](https://rstudio.cloud/) lessons you can use right away in your browser.

You can also access links to all these tutorials in the **"Get Started"** section from the top of this page.

<br>
<br>

# User Guide

Written by the authors of the **rmarkdown** package, [R Markdown: The Definitive Guide](https://bookdown.org/yihui/rmarkdown/) provides a comprehensive user guide to the complete R Markdown ecosystem for authoring documents. The book is published by Chapman & Hall/CRC, and you can read it online for free.

<a href="https://bookdown.org/yihui/rmarkdown/"><img src="https://bookdown.org/yihui/rmarkdown/images/cover.png" alt="R Markdown: The Definitive Guide" data-external=1 width="250" style="padding: 0 15px; float: right;"/></a>

The book is structured into four parts:

* [Part I](https://bookdown.org/yihui/rmarkdown/installation.html) introduces how to install the relevant packages, and provides an overview of R Markdown, including the possible output formats, the Markdown syntax, the R code chunk syntax, and how to use other languages in R Markdown.

* [Part II](https://bookdown.org/yihui/rmarkdown/documents.html) is the detailed documentation of built-in output formats in the rmarkdown package, including document formats and presentation formats. These output formats are "built-in" because you do not need any other R packages other than rmarkdown to use them.

* [Part III](https://bookdown.org/yihui/rmarkdown/dashboards.html) documents several R Markdown extension packages that enable you to build different applications or generate output documents with different styles. These output formats are "extensions" because you will need to install R packages, in addition to rmarkdown, to use them.

* [Part IV](https://bookdown.org/yihui/rmarkdown/parameterized-reports.html) covers advanced topics about R Markdown.

<br>
<br>

# Going further with examples

<a href="https://bookdown.org/yihui/rmarkdown-cookbook/"><img src="https://bookdown.org/yihui/rmarkdown-cookbook/images/cover.png" alt="R Markdown Cookbook" data-external=1 width="250" style="padding: 0 15px; float: right;"/></a>

[R Markdown Cookbook](https://bookdown.org/yihui/rmarkdown-cookbook/) provides a range of examples on how to extend the functionality of your R Markdown documents. As a cookbook, this guide is recommended to new and intermediate R Markdown users who desire to enhance the efficiency of using R Markdown and also explore the power of R Markdown. The book is published by Chapman & Hall/CRC, and you can read it online for free.

This cookbook is not a full technical reference for R Markdown but aims to supplement, instead of replace, the existing literature. The book is thus organized by topics with example as self-contained as possible so that readers can read this book with specific tasks in mind to do with R Markdown. 

The topics are the following

```{r, results='asis', echo = FALSE, eval = FALSE}
# run this to update the content below
xfun::pkg_attach2("xml2")
html <- read_html("https://bookdown.org/yihui/rmarkdown-cookbook/")
chapters <- xml_find_all(html, "//li[@class='chapter']")
first_level <- chapters[which(purrr::map_lgl(xml_attr(chapters, 'data-level'), ~ grepl('^\\d+$', .x)))]
titles <- xml_text(xml_find_all(first_level, "a"))
titles <- gsub("^(\\d+)", "\\1.", titles)
titles <- gsub("^(.*) \\([*])$", "\\1", titles)
url <- file.path("https://bookdown.org/yihui/rmarkdown-cookbook", xml_attr(first_level, "data-path"))
formatted <- sprintf("* [%s](%s)", titles, url)
cat(formatted, sep = "\n")
```

* [1. Installation](https://bookdown.org/yihui/rmarkdown-cookbook/installation.html)
* [2. Conceptual Overview](https://bookdown.org/yihui/rmarkdown-cookbook/conceptual-overview.html)
* [3. Basics](https://bookdown.org/yihui/rmarkdown-cookbook/basics.html)
* [4. Document Elements](https://bookdown.org/yihui/rmarkdown-cookbook/document-elements.html)
* [5. Formatting](https://bookdown.org/yihui/rmarkdown-cookbook/formatting.html)
* [6. LaTeX Output](https://bookdown.org/yihui/rmarkdown-cookbook/latex-output.html)
* [7. HTML Output](https://bookdown.org/yihui/rmarkdown-cookbook/html-output.html)
* [8. Word](https://bookdown.org/yihui/rmarkdown-cookbook/word.html)
* [9. Multiple Output Formats](https://bookdown.org/yihui/rmarkdown-cookbook/multi-formats.html)
* [10. Tables](https://bookdown.org/yihui/rmarkdown-cookbook/tables.html)
* [11. Chunk Options](https://bookdown.org/yihui/rmarkdown-cookbook/chunk-options.html)
* [12. Output Hooks](https://bookdown.org/yihui/rmarkdown-cookbook/output-hooks.html)
* [13. Chunk Hooks](https://bookdown.org/yihui/rmarkdown-cookbook/chunk-hooks.html)
* [14. Miscellaneous knitr Tricks](https://bookdown.org/yihui/rmarkdown-cookbook/knitr-misc.html)
* [15. Other Languages](https://bookdown.org/yihui/rmarkdown-cookbook/other-languages.html)
* [16. Managing Projects](https://bookdown.org/yihui/rmarkdown-cookbook/managing-projects.html)
* [17. Workflow](https://bookdown.org/yihui/rmarkdown-cookbook/workflow.html)

<br>
<br>

# Cheatsheets

<a href="https://raw.githubusercontent.com/rstudio/cheatsheets/main/rmarkdown.pdf"><img src="https://raw.githubusercontent.com/rstudio/cheatsheets/main/pngs/rmarkdown.png" alt="R Markdown cheatsheet" data-external=1 width="400" style="padding: 0 15px; float: right;"/></a>

The [R Markdown cheatsheet](https://raw.githubusercontent.com/rstudio/cheatsheets/main/rmarkdown.pdf) is a one page (two-sided) reference guide you can download as a quick reference while you work.

You can access it from within the RStudio IDE: 
 
- *Help > Cheatsheets >  
R Markdown Cheat Sheet*
