Overview

Installation

install.packages("rmarkdown")

How It Works

---
title:...
author:...
date:...
output:...
---

How It Works

Rendering output

library(rmarkdown)
rmarkdown::render("Lecture_4.1_Rmarkdown.Rmd", output_format = "word_document")
Picture 1

Picture 1

Rendering output

Picture 2

Picture 2

How it works

Picture 3

Picture 3

Code Chunks

Picture 4

Picture 4

Chunk Options

{r include = FALSE}

Include = FALSE prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks.

{r echo = FALSE}

echo = FALSE prevents code, but not the results from appearing in the finished file. This is a useful way to embed figures.

Chunk Options

{r message = FALSE }

message = FALSE prevents messages that are generated by code from appearing in the finished file.

{r warning = FALSE}

warning = FALSE prevents warnings that are generated by code from appearing in the finished.

{r fig.cap = "..."}

fig.cap = “…” adds a caption to graphical results.

Chunk Options

{r, out.width = "200px", fig.cap = "Example"}
image(volcano, col = viridis(200))
image(volcano, col = viridis(200))
Example

Example

Chunk Global Options

{r}
knitr::opts_chunk$set(echo = TRUE)

Dashboards

Dashboards

Dashboards example

Picture 4

Picture 4

Interactive Documents