Introduction to R Markdown

Reporting with R Markdown

Amy Peterson

Head of Core Curriculum at DataCamp

R Markdown

Business report

Reporting with R Markdown

Reproducible results

Markdown table

Reporting with R Markdown

Reproducible results

Markdown table with plot

Reporting with R Markdown

Reproducible results

Markdown table with an pointing to the plot and an arrow pointing back to the table

Reporting with R Markdown

Reproducible results

Markdown table with plot and warning sign

Reporting with R Markdown

R Markdown elements

Code

Markdown file code

Text

Markdown file text

Metadata

Markdown file metadata

Reporting with R Markdown

R Markdown file

R Markdown file with highlighted sections.png

Reporting with R Markdown

Knit

Markdown file.png

HTML file.png

Reporting with R Markdown

Course overview

Elements of an R Markdown document

Markdown file metadata

Add analyses and plots

Plot

Organize and improve a report

Organized report

Customize fonts and colors

Blocks that spell out brand

Reporting with R Markdown

Investment annual summary

investment_annual_summary
# A tibble: 42 x 3
   fiscal_year region                          dollars_in_millions
         <dbl> <chr>                                         <dbl>
 1        2012 East Asia and the Pacific                      2548
 2        2012 Europe and Central Asia                        2915
 3        2012 Latin America and the Caribbean                3680
 4        2012 Middle East and North Africa                   2210
 5        2012 South Asia                                     1312
# ... with 37 more rows
Reporting with R Markdown

Investment services projects

investment_services_projects
# A tibble: 1,838 x 13
   date_disclosed      country ifc_country_code sector project_name project_number
   <dttm>              <chr>    <chr>            <chr>    <chr>                    <dbl>
 1 2018-06-29 00:00:00 India     IND              Manuf... Camlin                  39750
 2 2018-06-28 00:00:00 Latin ... LAC              Funds    Riverwood I...          41148
 3 2018-06-26 00:00:00 Zambia    ZAM              Finan... Stanbic Ban...          38700
 4 2018-06-22 00:00:00 Thaila... THL              Finan... Roojai                  40653
 5 2018-06-22 00:00:00 China     CHA              Agrib... Chenguang B...          40616
# ... with 1,833 more rows, and 7 more variables: company_name <chr>, status <chr>,
#   risk_management_investment <dbl>, guarantee_investment <dbl>, loan_investment <dbl>,
#   equity_investment <dbl>, total_investment <dbl>
Reporting with R Markdown

Code chunks

Markdown file with highlighted code chunk.png

Reporting with R Markdown

Adding code chunks

Empty code chunk.png

Reporting with R Markdown

Adding code chunks

empty code chunk with labeled backticks.png

Reporting with R Markdown

Adding code chunks

empty code chunk with labeled curly braces.png

Reporting with R Markdown

Adding code chunks

Code chunk with dataset name.png

Reporting with R Markdown

Adding code chunks

Knit file with investment_annual_summary

Reporting with R Markdown

Let's practice!

Reporting with R Markdown

Preparing Video For Download...