-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfigure1.R
61 lines (52 loc) · 2.52 KB
/
figure1.R
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
library(tidyverse)
library(ggpubr)
library(scales)
figure1_idbanks_A <- c("001763117", "001766089")
figure1_idbanks_B <- c("001763012", "001763620")
figure1_A <- paste(figure1_idbanks_A, collapse = "+") |>
paste0("https://www.bdm.insee.fr/series/sdmx/data/SERIES_BDM/", i = _) |>
rsdmx::readSDMX() |>
tibble::as_tibble() |>
transmute(date = as.Date(paste0(TIME_PERIOD, "-01-01")),
OBS_VALUE = as.numeric(OBS_VALUE),
`IPC ou IPCH ?` = case_when(grepl("harmonisé", TITLE_FR) ~ "IPCH",
T ~ "IPC")) %>%
filter(date >= as.Date("1996-01-01"),
date <= as.Date("2024-06-01")) %>%
ggplot() + ylab("Pondération, 06 - Santé") + xlab("") + theme_minimal() +
geom_line(aes(x = date, y = OBS_VALUE/10000, color = `IPC ou IPCH ?`)) +
scale_x_date(breaks = seq(1920, 2100, 2) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%Y")) +
theme(legend.position = c(0.7, 0.55),
legend.title = element_blank(),
axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
scale_y_continuous(breaks = 0.01*seq(0, 300, 1),
labels = percent_format(accuracy = 1))
figure1_A
figure1_B <- paste(figure1_idbanks_B, collapse = "+") |>
paste0("https://www.bdm.insee.fr/series/sdmx/data/SERIES_BDM/", i = _) |>
rsdmx::readSDMX() |>
tibble::as_tibble() |>
transmute(date = as.Date(paste0(TIME_PERIOD, "-01")),
OBS_VALUE = as.numeric(OBS_VALUE),
`IPC ou IPCH ?` = case_when(grepl("harmonisé", TITLE_FR) ~ "IPCH",
T ~ "IPC")) %>%
group_by(`IPC ou IPCH ?`) %>%
filter(date >= as.Date("1996-01-01"),
date <= as.Date("2024-06-01")) %>%
arrange(date) %>%
mutate(OBS_VALUE = 100*OBS_VALUE/OBS_VALUE[1]) %>%
ggplot() + ylab("Indice de prix - Santé (100 = 1996)") + xlab("") + theme_minimal() +
geom_line(aes(x = date, y = OBS_VALUE, color = `IPC ou IPCH ?`)) +
scale_x_date(breaks = seq(1920, 2100, 2) %>% paste0("-01-01") %>% as.Date,
labels = date_format("%Y")) +
theme(legend.position = c(0.7, 0.55),
legend.title = element_blank(),
axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
scale_y_log10(breaks = seq(10, 300, 5),
labels = dollar_format(accuracy = 1, prefix = "")) +
labs(caption = "Source: Insee")
figure1_B
ggarrange(figure1_A, figure1_B, common.legend = T)
ggsave("figure1.png", width = 1.25*6, height = 1.25*3.375, bg = "white")
ggsave("figure1.pdf", width = 1.25*6, height = 1.25*3.375)