---
title: "Bayesian Statistics and Computing"
author: "Yanfei Kang"
date: '2020/02/10 (updated: `r Sys.Date()`)'
# output: slidy_presentation
output:
  # html_document: default
  # pdf_document: default
  word_document: default
subtitle: 'Lecture 6: Reproducible learning via `rmarkdown`'
bibliography: refs.bib
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(tidy = TRUE, 
                      echo = TRUE,
                      warning = FALSE,
                      message = FALSE)
```



## Why R markdown?

- Much **easier** *syntax* ~~syntax~~ than LaTex or Html
- Dynamic: easy to update and work with the R codes
- Multiple output formats
- Makes presentation easy
- Keep me (and my group) organized of weekly research progress reports, slides, papers etc.



## Header 1
### Header 2


## Creation of lists
### unordered
- Item 1
- Item 2

### ordered
1. Item 1
2. Item 2
    + item 2a
    + item 2b


## Inline codes
Write inline **R** code using backtick quotes: `forecast()`.


## Equations

- $x + y = z$ for inline equations
- $$ x^2 + \sqrt{(y)} = \epsilon $$ 


## Hyperlink

1. [R markdown website](http://rmarkdown.rstudio.com)

2. [R markdown guide](https://bookdown.org/yihui/rmarkdown/)

************************************

## R code with errors

```{r, error=TRUE}
x > 1
```

## R code chunks with plot 

See @hong2014global.

```{r RcodeDemoPlot, fig.width=8, fig.height=4, echo=TRUE, eval=FALSE, cache=TRUE}
library(tscompdata)
library(ggplot2)
library(forecast)
autoplot(gefcom2012_temp$`1`) +
  ggtitle('Temperature') +
  xlab('Time')
```


## Interactive plots

You can use interactive plots for if you output html documents.

```{r RcodeDemoPlotly, fig.width=8, fig.height=4, echo=FALSE, eval=TRUE}
# library(tscompdata)
# library(ggplot2)
# library(forecast)
# library(plotly)
# p <- autoplot(gefcom2012_temp$`1`) +
#   ggtitle('Temperature') +
#   xlab('Time')
# ggplotly(p)
```


## R code chunks with table
```{r RcodeDemoTable}
knitr::kable(head(iris))
```



## Plain code block 

```
library(forecast)
library(ggplot2)
autoplot(AirPassengers)
```


## References




