knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(ggsano)
library(ggsano) ## style
library(dplyr) ## data management
library(tidyr) ## data management
library(ggplot2) ## plot
load("../R/sysdata.rda")

Create a single line chart

#Data for chart from gapminder package
line_df <- dta %>%
  filter(CAUSE == "ALL CAUSES" &
           REGIOJ == "Belgium" &
           MEASURE == "Deaths" &
           METRIC == "Rate" &
           AGEGRP == "ALL" &
           SEX == "Both sexes")

#Get Sciensano color
col <- pal_sciensano()(1)

#Make plot
line <- ggplot(line_df, aes(x = YEAR, y = VAL_MEAN)) +
  geom_line(colour = col, size = 1) +
  geom_hline(yintercept = 0, size = 1, colour="#333333") +
  sciensano_style() +
  labs(title="Deaths",
       subtitle = "Number of deaths in Belgium 2004-2018")
line

Create a multiple line chart

#Data for chart from gapminder package
line_df <- dta %>%
  filter(CAUSE == "ALL CAUSES" &
           REGIOJ %in% c("Flanders", "Brussels", "Wallonia") &
           MEASURE == "Deaths" &
           METRIC == "Rate" &
           AGEGRP == "ALL" &
           SEX == "Both sexes")

#Make plot
line <- ggplot(line_df, aes(x = YEAR, y = VAL_MEAN, color = REGIOJ)) +
  geom_line(size = 1) +
  geom_hline(yintercept = 0, size = 1, colour="#333333") +
  sciensano_style() +
  scale_color_sciensano() +
  labs(title="Deaths",
       subtitle = "Number of deaths in Brussels, Flanders, and Wallonia")
line


sciensanogit/ggsano documentation built on April 14, 2022, 8:57 p.m.