1 Before we start

1.1 Prerequisites

Please run this chunk of code below in your R session. It will install all the packages we need during the course.

install.packages('devtools')

devtools::install_cran(
  pkgs = c(
    'tidyverse',     # tools for tidy data analysis
    'rmarkdown',     # literate programming
    'plotly',        # interactive visualization
    'ggmap',         # use online map-tiles with ggplot
    'eurostat',      # download data from eurostat
    'sf',            # tidy geo-computing
    'rnaturalearth', # download worldwide map data
    'gapminder',     # data from the gapminder world project
    'cowplot',       # ggplot multiple figures addon
    'skimr',         # nice dataframe summaries
    'broom'          # convert R objects to tidy dataframes
  ),
  repos = "https://cran.rstudio.com/"
)

1.2 Literate programming in Rmarkdown

The official Rmarkdown cheat sheet.

1.2.1 Excercise: Literate programming in Rmarkdown

  • Rewrite any of your existing R-scripts into an Rmarkdown script. Demonstrate loading data from the hard disc, plot output, text blocks, headers and lists. Export to pdf.