Here’s a first-level header

And a second-level

And a third-level

This could be some narrative text for framing my code and analysis. We’ll begin with loading packages and data.

library(tidyverse)
df <- read_csv("./data/original/gapminder.csv")

We included “message=FALSE” in the code chunk options to avoid some console printouts that interrupt the flow of the document.

Next, we’ll print the data in a nice-looking way using the kable function from knitr, which was downloaded automatically as part of rmarkdown. We’ll use head(df) to only print the first few rows rather than the entire data set.

knitr::kable(head(df))
country continent year lifeExp pop gdpPercap
Afghanistan Asia 1952 28.801 8425333 779.4453
Afghanistan Asia 1957 30.332 9240934 820.8530
Afghanistan Asia 1962 31.997 10267083 853.1007
Afghanistan Asia 1967 34.020 11537966 836.1971
Afghanistan Asia 1972 36.088 13079460 739.9811
Afghanistan Asia 1977 38.438 14880372 786.1134

Next, we’ll embed a plot we can make with the data

ggplot(df, aes(x = gdpPercap, y = lifeExp)) +
  geom_point(aes(size = pop, color = continent)) +
  scale_x_log10() +
  facet_wrap(~year) +
  labs(
    title = "Life Expectancy and GDP Per Capita",
    subtitle = "1952 - 2007",
    x = "GDP Per Capita (USD)",
    y = "Life Expectancy",
    color = "Continent",
    size = "Population",
    caption = "Data from gapminder.com"
  ) +
  theme_bw()

We’ll include a link to the data source, as well. You can find the original data from Gapminder or the processed version we’re using from Jenny Bryan’s gapminder package.