0.1 What can RMarkdown be used for?

  1. HTML Reports & PDF Reports
  2. HTML Slide Decks & PowerPoint
  3. Interactive Dashboards
  4. Books with bookdown
  5. Websites with blogdown

0.2 Key Resources

# PDF Knitting Setup: https://yihui.name/tinytex/
# install.packages("tintex")
# tinytex::install_tinytex()

1 Write with Markdown

2 Header 1

2.1 Header 2

2.1.1 Header 3

Plain text.

Type bold.

Type italics.

Type bold + italics.

Talk about code - the tidyverse is awesome

Unordered List:

  • Item 1
  • Item 2

Ordered List:

  1. First point
  2. Second point
  3. More points

3 Tabset

3.1 Tab 1

This is Tab 1

3.2 Tab 2

This is Tab 2

4 Images

PSU Logo

PSU Logo

PSU Logo

5 Code

# Import stock prices
stocks <- tq_get(c("AMZN", "MSFT"),
                 get = "stock.prices",
                 from = "2016-01-01",
                 to = "2023-01-01")
stocks
## # A tibble: 3,524 × 8
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 AMZN   2016-01-04  32.8  32.9  31.4  31.8 186290000     31.8
##  2 AMZN   2016-01-05  32.3  32.3  31.4  31.7 116452000     31.7
##  3 AMZN   2016-01-06  31.1  32.0  31.0  31.6 106584000     31.6
##  4 AMZN   2016-01-07  31.1  31.5  30.3  30.4 141498000     30.4
##  5 AMZN   2016-01-08  31.0  31.2  30.3  30.4 110258000     30.4
##  6 AMZN   2016-01-11  30.6  31.0  29.9  30.9  97832000     30.9
##  7 AMZN   2016-01-12  31.3  31.3  30.6  30.9  94482000     30.9
##  8 AMZN   2016-01-13  31.0  31.0  29.0  29.1 153104000     29.1
##  9 AMZN   2016-01-14  29.0  30.1  28.5  29.6 144760000     29.6
## 10 AMZN   2016-01-15  28.6  29.2  28.3  28.5 155690000     28.5
## # … with 3,514 more rows

6 Plots

Plotting works as expected. Try changing:

Static plots:

g <- ggplot(data = stocks) +
  geom_point(mapping = aes(x = volume, y = adjusted, color = symbol))
g
Revenue by Category

Revenue by Category

Interactive plots:

ggplotly(g)

7 Tables

Static Tables:

stocks %>% head() %>% knitr::kable()
symbol date open high low close volume adjusted
AMZN 2016-01-04 32.8145 32.8860 31.3755 31.8495 186290000 31.8495
AMZN 2016-01-05 32.3430 32.3455 31.3825 31.6895 116452000 31.6895
AMZN 2016-01-06 31.1000 31.9895 31.0155 31.6325 106584000 31.6325
AMZN 2016-01-07 31.0900 31.5000 30.2605 30.3970 141498000 30.3970
AMZN 2016-01-08 30.9830 31.2070 30.3000 30.3525 110258000 30.3525
AMZN 2016-01-11 30.6240 30.9925 29.9285 30.8870 97832000 30.8870

Dynamic Tables:

stocks
## # A tibble: 3,524 × 8
##    symbol date        open  high   low close    volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>     <dbl>    <dbl>
##  1 AMZN   2016-01-04  32.8  32.9  31.4  31.8 186290000     31.8
##  2 AMZN   2016-01-05  32.3  32.3  31.4  31.7 116452000     31.7
##  3 AMZN   2016-01-06  31.1  32.0  31.0  31.6 106584000     31.6
##  4 AMZN   2016-01-07  31.1  31.5  30.3  30.4 141498000     30.4
##  5 AMZN   2016-01-08  31.0  31.2  30.3  30.4 110258000     30.4
##  6 AMZN   2016-01-11  30.6  31.0  29.9  30.9  97832000     30.9
##  7 AMZN   2016-01-12  31.3  31.3  30.6  30.9  94482000     30.9
##  8 AMZN   2016-01-13  31.0  31.0  29.0  29.1 153104000     29.1
##  9 AMZN   2016-01-14  29.0  30.1  28.5  29.6 144760000     29.6
## 10 AMZN   2016-01-15  28.6  29.2  28.3  28.5 155690000     28.5
## # … with 3,514 more rows

8 Footnotes

This is some text with a Footnote1. This is a second Footnote2.


  1. Citation for Footnote 1↩︎

  2. Citatin for Footnote 2↩︎