Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

.Rhistory 2.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  1. knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
  2. pacman::p_load(tidyverse, tsibble, fable, plotly, urca, feasts, readxl, lubridate,
  3. janitor, scales, lemon, gghighlight, ggrepel, patchwork, extrafont,
  4. RColorBrewer, glue, Metrics, directlabels, WDI, eurostat,
  5. update = FALSE, install = FALSE)
  6. stmf_data <- read_csv("https://www.mortality.org/Public/STMF/Outputs/stmf.csv", skip = 2) %>%
  7. rename_all(tolower)
  8. knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
  9. pacman::p_load(tidyverse, tsibble, fable, plotly, urca, feasts, readxl, lubridate,
  10. janitor, scales, lemon, gghighlight, ggrepel, patchwork, extrafont,
  11. RColorBrewer, glue, Metrics, directlabels, WDI, eurostat,
  12. update = FALSE, install = FALSE)
  13. stmf_data <- read_csv("https://www.mortality.org/Public/STMF/Outputs/stmf.csv", skip = 2) %>%
  14. rename_all(tolower)
  15. nrow(stmf_data)
  16. stmf_country_codes <- read_excel("data/hmd_stmf_country_codes.xlsx")
  17. stmf_country_codes <- read_excel("data/hmd_stmf_country_codes.xlsx")
  18. head(search_eurostat("Deaths by week and sex"))
  19. eurostat_data <- get_eurostat("demo_r_mwk_ts", time_format = "raw")
  20. eurostat_data <- label_eurostat(eurostat_data, custom_dic = c(DE = "Germany",
  21. UK = "The United Kingdom"))
  22. eurostat_data <- eurostat_data %>%
  23. rename(country_name = geo,
  24. value = values) %>%
  25. mutate(year = str_sub(time,1,4),
  26. year = as.integer(year),
  27. week = str_sub(time,6,7),
  28. week = as.integer(week),
  29. dtotal = value) %>%
  30. filter(sex == "Total") %>%
  31. filter(week != 99) %>%
  32. filter(year >= 2015) %>%
  33. arrange(country_name, year, week) %>%
  34. select(country_name, year, week, dtotal) %>%
  35. rename(time = week, deaths = dtotal) %>%
  36. mutate(time_unit = "weekly",
  37. source = "EuroStat") %>%
  38. filter(country_name != "Andora")
  39. eurostat_data
  40. eurostat_data %>% tabyl(country_name)
  41. knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
  42. pacman::p_load(tidyverse, tsibble, fable, plotly, urca, feasts, readxl, lubridate,
  43. janitor, scales, lemon, gghighlight, ggrepel, patchwork, extrafont,
  44. RColorBrewer, glue, Metrics, directlabels, WDI, eurostat,
  45. update = FALSE, install = FALSE)
  46. stmf_data <- read_csv("https://www.mortality.org/Public/STMF/Outputs/stmf.csv", skip = 2) %>%
  47. rename_all(tolower)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...