Statistics for the COVID-19 outbreak in Sweden

This page provides plots and visualisations of currently available statistics for the novel coronavirus (COVID-19) outbreak in Sweden.

This page is largely the result of a personal exercise in data analysis but since it received some interest on Twitter, I have set this page to automatically update every day following the daily updates of the national statistics from Sweden's Public Health Authority (Folkhälsomyndigheten).

The data presented here is scraped from a publicly available source (c19.se), and I am not responsible for the accuracy of these numbers. The code used to produce the images on this page is provided below if you would like to reproduce these or see how it is done.

Please note: occasionally c19.se subtly changes their webpage which breaks my code and may cause this page not to be updated correctly, or at all. Since I don't actively check/maintain this page, I might not notice. If this happens feel free to leave a comment below so I will notice, and I can try to fix the problem. Sorry in advance for any disappointment...

Total confirmed cases and deaths in Sweden

Summary of confirmed cases and deaths in Sweden per day, showing the current 7-day moving average.

Total confirmed cases in Sweden per day

Confirmed deaths in Sweden per day

Total confirmed cases per 100k inhabitants, by county

Total deaths per 100k inhabitants, by county

Current cases, deaths, hospitalisations and ICU admissions by county, per 100k inhabitants

Cases reported today per 100k inhabitants, by county

Deaths reported today per 100k inhabitants, by county

Hospitalisations per 100k inhabitants, by county

ICU admissions per 100k inhabitants, by county

Regional trends

Total confirmed cases per day by county, per 100k inhabitants

Total confirmed deaths per day by county, per 100k inhabitants

The below charts show the change in cases and deaths by county over the last 7 days relative to the previous 7-day period. This means that a value over zero means the number new cases/deaths may be increasing with time, and under zero means they may be decreasing. Infinite values are removed.

Week-to-week increase in cases by county

Week-to-week increase in deaths by county

Code

Below is the code, written in R, used to scrape the data from the web and produce the above images. This might be of interest to those with an interest in data science or analysis as it contains examples of web scraping, all manner of data wrangling with tidyverse, simple calculations, plotting with ggplot, choropleth maps, and so on.

The geoJSON shapefile used to produce the choropleth maps was downloaded from here and re-hosted at this site for convenience.

The code here is essentially the same as run on this website's server to generate the images on the page here; the only difference is the data frame map_tidy is pre-exported as a text file so it is not created from the geoJSON file every time. Cron then runs the script and re-builds the page every day.

# Setting the locale may be necessary; it is on the server but not on my Mac.
#Sys.setlocale(locale = "sv_SE.utf8")

# load necessary packages
library(rvest)
library(tidyverse)
library(viridis)
library(geojsonio)
library(broom)
library(ggrepel)
library(lubridate)
library(mapproj)
library(zoo)

# Set the export folder
exp_folder <- "~/"

### 1. Importing map data ###

# Read in geoJSON shapefile and convert to dataframe
spdf <- geojson_read("http://lacey.se/dl/sweden.geojson", what = "sp") %>% tidy

# Need to match 'id' in the shapefile to the name of the county,
# so we make a dataframe of ids and county names
map_ids <- data.frame(
  id = c(1:21),
  county = c("Stockholm", "Västmanland", "Värmland", "Örebro", "Jämtland", "Blekinge",
             "Uppsala", "Sörmland", "Östergötland", "Gotland", "Jönköping", "Kronoberg",
             "Västernorrland", "Kalmar", "Skåne", "Halland", "Gävleborg", "Västra Götaland",
             "Dalarna", "Västerbotten", "Norrbotten")
)

# Make the new map dataframe by merging the two.
map_tidy <- merge(spdf, map_ids)

# Create the dataframe
counties <- data.frame(
  county = c("Stockholm", "Västmanland", "Värmland", "Örebro", "Jämtland", "Blekinge",
             "Uppsala", "Sörmland", "Östergötland", "Gotland", "Jönköping", "Kronoberg",
             "Västernorrland", "Kalmar", "Skåne", "Halland", "Gävleborg", "Västra Götaland",
             "Dalarna", "Västerbotten", "Norrbotten"),
  pop = c(2344124, 273929, 281482, 302252, 130280, 159684, 376354, 294695, 461583, 59249,
          360825, 199886, 245453, 244670, 1362164, 329352, 286547, 1709814, 287191, 270154,
          250497)
)

### Scraping data from c19.se. ###
# Scrape the data as needed and then reformat where necessary

# Need a new function to remove commas
rmcomma <- function(x) as.numeric(gsub(",", "", x))
rmspace <- function(x) as.numeric(gsub(" ", "", x))

# Scrape data for the latest day only, from the homepage.
# Find the relevant table, rename columns, merge with the counties dataframe
# and calculate population-level data by county
c19se_today <- "https://c19.se" %>%
  read_html() %>%
  html_nodes(xpath='//*[@id="tableCell"]') %>%
  html_table() %>%
  .[[1]] %>%
  #  slice(1:n()-1) %>%
  rename(county = Region, cases = Fall, casestoday = `Fall idag`, hospital = `På sjukhus`, icu = `På IVA`,
         deaths = `Döda`, deathstoday = `Döda idag`) %>%
  mutate_at(.vars = vars(cases, casestoday, hospital, icu, deaths, deathstoday),
            .funs = rmspace) %>%
  merge(counties, by = "county") %>%
  mutate(cases_norm = 1E5 * cases / pop, deaths_norm = 1E5 * deaths / pop,
         hospital_norm = 1E5 * hospital / pop, icu_norm = 1E5 * icu / pop,
         casestoday_norm = 1E5 * casestoday / pop, deathstoday_norm = 1E5 * deathstoday / pop)


# Scrape pages for individual regions. Looks through the sub-page for each region,
# takes the relevant data, combines, renames and processes as desired.
# c19.se only shows data for the last 30 days, so at the last step the numbers of
# cases and deaths are shifted according to the number of cases/deaths which had
# been reported prior to the first date in the individual tables.
c19se <- lapply(counties$county, function(county) {
  paste("https://c19.se/Sweden/", county, sep = "") %>%
    read_html() %>%
    html_nodes(xpath = '/html/body/main/section/div/div/table[1]') %>%
    html_table() %>%
    .[[1]] %>%
    slice(1:n()-1) %>%
    rename(day = Dag, cases = Fall, deaths = Döda, casestoday = `Fall idag`,
           deathstoday = `Döda idag`) %>%
    mutate_at(.vars = vars(cases, casestoday, deaths, deathstoday),
              .funs = rmcomma) %>%
    mutate(county = county)
}) %>%
  do.call(rbind, .) %>%
  merge(counties, by = "county") %>%
  mutate(day = as.Date(day)) %>%
  arrange(county, day) %>%
  group_by(county) %>%
  mutate(cases_norm = 1E5 * cases / pop, deaths_norm = 1E5 * deaths / pop,
         casestoday_norm = 1E5 * casestoday / pop, deathstoday_norm = 1E5 * deathstoday / pop,
         mavcases_norm = rollmean(casestoday_norm, 7, fill = NA, align = "right"),
         mavdeaths_norm = rollmean(deathstoday_norm, 7, fill = NA, align = "right"))

### Combine with map data and plot

# Create dataframe to plot choropleth maps by merging statistics with map data
c19se_today_map <- c19se_today %>%
  merge(map_tidy, by = "county") %>%
  arrange(order, group)

# For indicating cities, need to create tables of cities with their geographical
# coordinates. We'll take the three largest cities in Sweden and a random selection
# of smaller cities/towns to keep the maps interesting. First create the table for big
# cities
bigcities <- structure(list(city = structure(c(3L, 1L, 2L), .Label = c("Göteborg",
                                                                       "Malmö", "Stockholm"), class = "factor"), lat = c(59.3293, 57.7089,
                                                                                                                         55.605), long = c(18.0686, 11.9746, 13.0038)), class = "data.frame", row.names = c(NA,
                                                                                                                                                                                                            -3L))
# Then equivalent table for 51 smaller towns/cities
cities2 <- structure(list(city = structure(c(47L, 46L, 49L, 32L, 26L, 15L,
                                             18L, 30L, 28L, 45L, 11L, 5L, 38L, 7L, 12L, 50L, 21L, 40L, 34L,
                                             43L, 27L, 6L, 23L, 19L, 37L, 31L, 20L, 44L, 36L, 48L, 24L, 33L,
                                             2L, 17L, 22L, 13L, 1L, 29L, 9L, 14L, 25L, 16L, 51L, 8L, 4L, 10L,
                                             41L, 3L, 35L, 39L, 42L), .Label = c("Abisko", "Åre", "Arvika",
                                                                                 "Boden", "Borås", "Borlänge", "Eskilstuna", "Falun", "Flen",
                                                                                 "Gällivare", "Gävle", "Halmstad", "Haparanda", "Härnösand",
                                                                                 "Helsingborg", "Hudiksvall", "Jokkmokk", "Jönköping", "Kalmar",
                                                                                 "Karlskrona", "Karlstad", "Kiruna", "Kristianstad", "Landskrona",
                                                                                 "Leksand", "Linköping", "Luleå", "Lund", "Mora", "Norrköping",
                                                                                 "Nyköping", "Örebro", "Örnsköldsvik", "Östersund", "Sälen",
                                                                                 "Skellefteå", "Skövde", "Södertälje", "Storuman", "Sundsvall",
                                                                                 "Sveg", "Tärnaby", "Trollhättan", "Uddevalla", "Umeå", "Upplands Väsby",
                                                                                 "Uppsala", "Varberg", "Västerås", "Växjö", "Visby"), class = "factor"),
                          lat = c(59.8586, 59.5196, 59.6099, 59.2753, 58.4108, 56.0465,
                                  57.7826, 58.5877, 55.7047, 63.8258, 60.6749, 57.721, 59.1954,
                                  59.3712, 56.6744, 56.879, 59.4022, 62.3908, 63.1767, 58.2835,
                                  65.5848, 60.4843, 56.0294, 56.6634, 58.3903, 58.7528, 56.1612,
                                  58.3498, 64.7502, 57.1071, 55.8703, 63.29, 63.399, 66.607,
                                  67.8558, 65.8417, 68.3495, 61.0049, 59.0579, 62.6323, 60.7303,
                                  61.7274, 57.6348, 60.6065, 65.8251, 67.1379, 62.0346, 59.6549,
                                  61.1614, 65.0956, 65.71), long = c(17.6389, 17.9283, 16.5448,
                                                                     15.2134, 15.6214, 12.6945, 14.1618, 16.1924, 13.191, 20.263,
                                                                     17.1413, 12.9398, 17.6257, 16.5098, 12.8578, 14.8059, 13.5115,
                                                                     17.3069, 14.6361, 12.2858, 22.1567, 15.434, 14.1567, 16.3568,
                                                                     13.8461, 17.0092, 15.5869, 11.9356, 20.9509, 12.2521, 12.8301,
                                                                     18.7166, 13.0815, 19.8229, 20.2253, 24.1277, 18.8312, 14.537,
                                                                     16.5879, 17.9409, 14.9999, 17.1074, 18.2948, 15.6355, 21.6887,
                                                                     20.6594, 14.359, 12.5921, 13.263, 17.1123, 15.268)), class = "data.frame", row.names = c(NA,
                                                                                                                                                              -51L))

# Summary data

## Summary data for the whole country.
summary <- c19se %>%
  group_by(day) %>%
  summarise(sum_cases = sum(cases), sum_deaths = sum(deaths),
            sum_casestoday = sum(casestoday), sum_deathstoday = sum(deathstoday)) %>%
  mutate(cases = rollmean(sum_casestoday, 7, fill = NA, align = "right"),
         deaths = rollmean(sum_deathstoday, 7, fill = NA, align = "right"))

# Want to show full data set as background. To do this, making a copy but renaming
# county column so that it shows in every facet in the plot.
c19se_blank <- c19se %>%
  ungroup %>%
  rename(county_ = county)

# Increase in cases and deaths in last week compared to the previous week.
# Metric means that numbers over 0 mean cases/deaths are increasing, under 0
# means decreasing.
incr <- c19se %>%
  ungroup %>%
  filter(day %in% (today() - 13):today()) %>%
  group_by(county) %>%
  summarise(casesthisweek = sum(casestoday[8:14]), caseslastweek = sum(casestoday[1:7]),
            deathsthisweek = sum(deathstoday[8:14]), deathslastweek = sum(deathstoday[1:7]),
            incrcases = (sum(casestoday[8:14]) / sum(casestoday[1:7])) - 1,
            incrdeaths = (sum(deathstoday[8:14]) / sum(deathstoday[1:7])) - 1)

Creating images

### Create images
summary %>%
  ggplot(aes(x = day)) +
  geom_bar(aes(y = sum_casestoday), stat = "identity", alpha = 0.4) +
  geom_path(aes(y = cases), size = 0.8, color = "#0789ce") +
  scale_color_discrete(labels = c("cases", "deaths")) +
  guides(color = FALSE) +
  theme_minimal() +
  labs(x = "", y = "total reported cases per day",
       title = paste("COVID-19 in Sweden:", last(summary$sum_cases), "cases,",
                     last(summary$sum_deaths), "deaths"),
       subtitle = paste("Confirmed new cases per day, 7-day rolling average\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

# Save  
ggsave(paste(exp_folder, "casessummary.png", sep = ""), width = 6, height = 4, units = "in", dpi = 300)

summary %>%
  ggplot(aes(x = day)) +
  geom_bar(aes(y = sum_deathstoday), stat = "identity", alpha = 0.4) +
  geom_path(aes(y = deaths), size = 0.8, color = "#0789ce") +
  scale_color_discrete(labels = c("cases", "deaths")) +
  guides(color = FALSE) +
  coord_cartesian(ylim = c(0, NA)) +
  theme_minimal() +
  labs(x = "", y = "total reported deaths per day",
       subtitle = paste("Confirmed new deaths per day, 7-day rolling average\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

# Save
ggsave(paste(exp_folder, "deathssummary.png", sep = ""), width = 6, height = 4, units = "in", dpi = 300)

# Create the plot, confirmed cases (log scale) vs day, faceted by region
c19se %>%
  ggplot(aes(x = day, y = mavcases_norm)) +
  geom_path(data = c19se_blank, aes(group = county_), color = "grey90", size = 0.4) +
  geom_path(aes(color = county), size = 0.8) +
  facet_wrap(~ county, nrow = 5) +
  theme_minimal() +
  scale_x_date(date_labels = "%d/%m") +
  guides(color = FALSE) +
  theme(axis.text.x = element_text(angle = -45, hjust = 0)) +
  labs(x = "", y = "confirmed cases per 100k inhabitants",
       title = "COVID-19 in Sweden",
       subtitle = paste("confirmed cases per 100k inhabitants by county\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

# Save
ggsave(paste(exp_folder, "cases_by_county.png", sep = ""), width = 6.5, height = 7.5, units = "in", dpi = 300)

# Create the plot, confirmed cases (log scale) vs day, faceted by region
c19se %>%
  ggplot(aes(x = day, y = mavdeaths_norm)) +
  geom_path(data = c19se_blank, aes(group = county_), color = "grey90", size = 0.4) +
  geom_path(aes(color = county), size = 0.8) +
  facet_wrap(~ county, nrow = 5) +
  theme_minimal() +
  scale_x_date(date_labels = "%d/%m") +
  coord_cartesian(ylim = c(0, NA)) +
  guides(color = FALSE) +
  theme(axis.text.x = element_text(angle = -45, hjust = 0)) +
  labs(x = "", y = "confirmed deaths per 100k inhabitants",
       title = "COVID-19 in Sweden",
       subtitle = paste("confirmed deaths per 100k inhabitants by county\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

# Save
ggsave(paste(exp_folder, "deaths_by_county.png", sep = ""), width = 6.5, height = 7.5, units = "in", dpi = 300)

# Confirmed cases per 100k.
# First randomly generate table of cities/towns to mark on the map.
# Using set.seed hopefully ensures different selection of cities every day.
set.seed(day(Sys.Date()) + 1)
cities_sample <- sample_n(cities2, 4) %>%
  rbind(bigcities)

# Create choropleth map
ggplot(c19se_today_map) +
  geom_polygon(aes(x = long, y = lat, group = group, fill = cases_norm), color = "black") +
  geom_polygon(data = filter(map_tidy, group %in% c(5.2, 19.2, 21.2)),
               aes(x = long, y = lat, group = group), fill = "white", color = "black") +
  geom_point(data = cities_sample, aes(x = long, y = lat), shape = 21, fill = "red", size = 2, stroke = 0.8, alpha = 0.7) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 0.6, seed = 1234) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 1, fill = NA, seed = 1234) +
  coord_map() +
  scale_fill_viridis("", limits = c(0, NA)) +
  theme_void() +
  labs(title = "COVID-19 in Sweden",
       subtitle = paste("Confirmed cases per 100,000 inhabitants\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

# Save
ggsave(paste(exp_folder, "cases_per_100k.png", sep = ""), width = 6.5, height = 6.5, units = "in", dpi = 300)

# Deaths per 100k
# Maps below are created using the same method as above
set.seed(day(Sys.Date()) + 2)
cities_sample <- sample_n(cities2, 4) %>%
  rbind(bigcities)

ggplot(c19se_today_map) +
  geom_polygon(aes(x = long, y = lat, group = group, fill = deaths_norm), color = "black") +
  geom_polygon(data = filter(map_tidy, group %in% c(5.2, 19.2, 21.2)),
               aes(x = long, y = lat, group = group), fill = "white", color = "black") +
  geom_point(data = cities_sample, aes(x = long, y = lat), shape = 21, fill = "red", size = 2, stroke = 0.8, alpha = 0.7) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 0.6, seed = 1234) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 1, fill = NA, seed = 1234) +
  coord_map() +
  scale_fill_viridis("", limits = c(0, NA)) +
  theme_void() +
  labs(title = "COVID-19 in Sweden",
       subtitle = paste("Deaths per 100,000 inhabitants\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

ggsave(paste(exp_folder, "deaths_per_100k.png", sep = ""), width = 6.5, height = 6.5, units = "in", dpi = 300)

# Hospitalisations per 100k
set.seed(day(Sys.Date()) + 3)
cities_sample <- sample_n(cities2, 4) %>%
  rbind(bigcities)

ggplot(c19se_today_map) +
  geom_polygon(aes(x = long, y = lat, group = group, fill = hospital_norm), color = "black") +
  geom_polygon(data = filter(map_tidy, group %in% c(5.2, 19.2, 21.2)),
               aes(x = long, y = lat, group = group), fill = "white", color = "black") +
  geom_point(data = cities_sample, aes(x = long, y = lat), shape = 21, fill = "red", size = 2, stroke = 0.8, alpha = 0.7) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 0.6, seed = 1234) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 1, fill = NA, seed = 1234) +
  coord_map() +
  scale_fill_viridis("", limits = c(0, NA)) +
  theme_void() +
  labs(title = "COVID-19 in Sweden",
       subtitle = paste("Hospitalisations per 100,000 inhabitants\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

ggsave(paste(exp_folder, "hospitalisations_per_100k.png", sep = ""), width = 6.5, height = 6.5, units = "in", dpi = 300)

# ICU per 100k
set.seed(day(Sys.Date()) + 4)
cities_sample <- sample_n(cities2, 4) %>%
  rbind(bigcities)

ggplot(c19se_today_map) +
  geom_polygon(aes(x = long, y = lat, group = group, fill = icu_norm), color = "black") +
  geom_polygon(data = filter(map_tidy, group %in% c(5.2, 19.2, 21.2)),
               aes(x = long, y = lat, group = group), fill = "white", color = "black") +
  geom_point(data = cities_sample, aes(x = long, y = lat), shape = 21, fill = "red", size = 2, stroke = 0.8, alpha = 0.7) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 0.6, seed = 1234) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 1, fill = NA, seed = 1234) +
  coord_map() +
  scale_fill_viridis("", limits = c(0, NA)) +
  theme_void() +
  labs(title = "COVID-19 in Sweden",
       subtitle = paste("ICU admissions per 100,000 inhabitants\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

ggsave(paste(exp_folder, "icu_per_100k.png", sep = ""), width = 6.5, height = 6.5, units = "in", dpi = 300)

set.seed(day(Sys.Date()) + 5)
cities_sample <- sample_n(cities2, 4) %>%
  rbind(bigcities)

# Create choropleth map
ggplot(c19se_today_map) +
  geom_polygon(aes(x = long, y = lat, group = group, fill = casestoday_norm), color = "black") +
  geom_polygon(data = filter(map_tidy, group %in% c(5.2, 19.2, 21.2)),
               aes(x = long, y = lat, group = group), fill = "white", color = "black") +
  geom_point(data = cities_sample, aes(x = long, y = lat), shape = 21, fill = "red", size = 2, stroke = 0.8, alpha = 0.7) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 0.6, seed = 1234) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 1, fill = NA, seed = 1234) +
  coord_map() +
  scale_fill_viridis("", limits = c(0, NA)) +
  theme_void() +
  labs(title = "COVID-19 in Sweden",
       subtitle = paste("Confirmed cases reported today per 100,000 inhabitants\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

# Save
ggsave(paste(exp_folder, "casestoday_per_100k.png", sep = ""), width = 6.5, height = 6.5, units = "in", dpi = 300)

set.seed(day(Sys.Date()) + 6)
cities_sample <- sample_n(cities2, 4) %>%
  rbind(bigcities)

# Create choropleth map
ggplot(c19se_today_map) +
  geom_polygon(aes(x = long, y = lat, group = group, fill = deathstoday_norm), color = "black") +
  geom_polygon(data = filter(map_tidy, group %in% c(5.2, 19.2, 21.2)),
               aes(x = long, y = lat, group = group), fill = "white", color = "black") +
  geom_point(data = cities_sample, aes(x = long, y = lat), shape = 21, fill = "red", size = 2, stroke = 0.8, alpha = 0.7) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 0.6, seed = 1234) +
  geom_label_repel(data = cities_sample, aes(x = long, y = lat, label = city),
                   force = 3, box.padding = unit(0.35, "lines"), size = 3,
                   alpha = 1, fill = NA, seed = 1234) +
  coord_map() +
  scale_fill_viridis("", limits = c(0, NA)) +
  theme_void() +
  labs(title = "COVID-19 in Sweden",
       subtitle = paste("Confirmed deaths reported today per 100,000 inhabitants\ndata: c19.se, fetched ", last(c19se$day), sep = ""))

# Save
ggsave(paste(exp_folder, "deathstoday_per_100k.png", sep = ""), width = 6.5, height = 6.5, units = "in", dpi = 300)

incr %>%
  ggplot(aes(x = reorder(county, incrcases), y = incrcases * 100)) +
  geom_bar(aes(fill = incrcases), stat = "identity") +
  geom_hline(yintercept = 0) +
  coord_flip() +
  scale_fill_viridis() +
  theme_minimal() +
  labs(y = "increase / %", x = "", title = "COVID-19 in Sweden",
       subtitle = paste("Rate of change in cases week-to-week, last 14 days (%)\ndata: c19.se, fetched ", last(c19se$day), sep = "")) +
  guides(fill = FALSE) +
  NULL
ggsave(paste(exp_folder, "incr_cases_bar.png", sep = ""), width = 5.5, height = 7, units = "in", dpi = 300)


incr %>%
  filter(is.finite(incrdeaths)) %>%
  ggplot(aes(x = reorder(county, incrdeaths), y = incrdeaths * 100)) +
  geom_bar(aes(fill = incrdeaths), stat = "identity") +
  geom_hline(yintercept = 0) +
  coord_flip() +
  scale_fill_viridis() +
  theme_minimal() +
  labs(y = "increase / %", x = "", title = "COVID-19 in Sweden",
       subtitle = paste("Rate of change in deaths week-to-week, last 14 days (%)\ndata: c19.se, fetched ", last(c19se$day), sep = "")) +
  guides(fill = FALSE) +
  NULL
ggsave(paste(exp_folder, "incr_deaths_bar.png", sep = ""), width = 5.5, height = 7, units = "in", dpi = 300)
comments powered by Disqus