Chapter 1: Introduction#

library(tidyverse)
theme_set(theme_minimal(base_size = 14))
── Attaching packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.3.2 ──
 ggplot2 3.4.1      purrr   1.0.1
 tibble  3.1.8      dplyr   1.1.0
 tidyr   1.3.0      stringr 1.5.0
 readr   2.1.4      forcats 1.0.0
── Conflicts ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
 dplyr::filter() masks stats::filter()
 dplyr::lag()    masks stats::lag()

Figure 1.1#

carb_rr <- c(1, 1.07, 1.06, 1.17, 1.28)
satfat_rr <- c(1, 0.96, 0.92, 0.85, 0.86)

df <-
  data.frame(
    quartile = seq(1, 5),
    Carbohydrates = carb_rr,
    SaturatedFat = satfat_rr
  )

df  %>%
  gather(Nutrient, RelativeRisk, -quartile) %>%  # convert to long format
  ggplot(aes(x = quartile, y = RelativeRisk, linetype = Nutrient)) +
  geom_line(linewidth = 1) +
  geom_point(size=2) +
  geom_hline(yintercept = 1,linetype='dashed') +
  theme(legend.position = c(0.3,0.8)) +
  theme(aspect.ratio = 1) +
  labs(
    y = "Relative risk of dying from any cause",
    x = "Quintiles of nutrient intake"
  )
_images/01-Intro_3_0.svg