Mean consumption expenditure by income quintile

Data - Eurostat

Info

source dataset .html .RData
eurostat hbs_str_t211 2024-11-08 2024-11-08
eurostat hbs_str_t223 2024-11-05 2024-11-08
insee bdf2017 2024-11-05 2023-11-21
insee if203 2024-11-05 2023-07-20

Data on housing

source dataset .html .RData
bdf RPP 2024-07-26 2024-07-01
bis LONG_PP 2024-08-09 2024-05-10
bis SELECTED_PP 2024-10-31 2024-10-31
ecb RPP 2024-10-08 2024-10-30
eurostat ei_hppi_q 2024-11-08 2024-11-08
eurostat hbs_str_t223 2024-11-05 2024-11-08
eurostat prc_hicp_midx 2024-11-01 2024-11-08
eurostat prc_hpi_q 2024-11-05 2024-10-09
fred housing 2024-11-01 2024-11-01
insee IPLA-IPLNA-2015 2024-11-05 2024-11-05
oecd housing 2024-09-15 2020-01-18
oecd SNA_TABLE5 2024-09-11 2023-10-19

Données sur l’inflation en France

source dataset .html .RData
insee bdf2017 2024-11-05 2023-11-21
insee ILC-ILAT-ICC 2024-11-05 2024-11-05
insee INDICES_LOYERS 2024-11-05 2024-11-05
insee IPC-1970-1980 2024-11-05 2024-11-05
insee IPC-1990 2024-11-05 2024-11-05
insee IPC-2015 2024-11-05 2024-11-05
insee IPC-PM-2015 2024-11-05 2024-11-05
insee IPCH-2015 2024-11-05 2024-11-05
insee IPGD-2015 2024-08-22 2024-10-26
insee IPLA-IPLNA-2015 2024-11-05 2024-11-05
insee IPPI-2015 2024-11-05 2024-11-05
insee IRL 2024-11-05 2024-11-05
insee SERIES_LOYERS 2024-11-05 2024-11-05
insee T_CONSO_EFF_FONCTION 2024-11-05 2024-07-18

Data on inflation

source dataset .html .RData
bis CPI 2024-07-01 2022-01-20
ecb CES 2024-10-08 2024-01-12
eurostat nama_10_co3_p3 2024-11-05 2024-10-09
eurostat prc_hicp_cow 2024-11-05 2024-10-08
eurostat prc_hicp_ctrb 2024-11-05 2024-10-08
eurostat prc_hicp_inw 2024-11-05 2024-11-08
eurostat prc_hicp_manr 2024-11-05 2024-10-08
eurostat prc_hicp_midx 2024-11-01 2024-11-08
eurostat prc_hicp_mmor 2024-11-05 2024-11-08
eurostat prc_ppp_ind 2024-11-05 2024-10-08
eurostat sts_inpp_m 2024-06-24 2024-10-08
eurostat sts_inppd_m 2024-11-05 2024-10-08
eurostat sts_inppnd_m 2024-06-24 2024-10-08
fred cpi 2024-11-01 2024-11-01
fred inflation 2024-11-01 2024-11-01
imf CPI 2024-06-20 2020-03-13
oecd MEI_PRICES_PPI 2024-09-15 2024-04-15
oecd PPP2017 2024-04-16 2023-07-25
oecd PRICES_CPI 2024-04-16 2024-04-15
wdi FP.CPI.TOTL.ZG 2023-01-15 2024-09-18
wdi NY.GDP.DEFL.KD.ZG 2024-09-18 2024-09-18

LAST_COMPILE

LAST_COMPILE
2024-11-08

Last

Code
hbs_str_t223 %>%
  group_by(time) %>%
  summarise(Nobs = n()) %>%
  arrange(desc(time)) %>%
  head(2) %>%
  print_table_conditional()
time Nobs
2020 7555
2015 9854

coicop

All

Code
hbs_str_t223 %>%
  left_join(coicop, by = "coicop") %>%
  group_by(coicop, Coicop) %>%
  summarise(Nobs = n()) %>%
  print_table_conditional()

2-digit

Code
hbs_str_t223 %>%
  filter(nchar(coicop) == 4) %>%
  left_join(coicop, by = "coicop") %>%
  group_by(coicop, Coicop) %>%
  summarise(Nobs = n()) %>%
  print_table_conditional()
coicop Coicop Nobs
CP01 Food and non-alcoholic beverages 931
CP02 Alcoholic beverages, tobacco and narcotics 931
CP03 Clothing and footwear 931
CP04 Housing, water, electricity, gas and other fuels 931
CP05 Furnishings, household equipment and routine household maintenance 931
CP06 Health 931
CP07 Transport 931
CP08 Communications 931
CP09 Recreation and culture 931
CP10 Education 926
CP11 Restaurants and hotels 931
CP12 Miscellaneous goods and services 931

3-digit

Code
hbs_str_t223 %>%
  filter(nchar(coicop) == 5) %>%
  left_join(coicop, by = "coicop") %>%
  group_by(coicop, Coicop) %>%
  summarise(Nobs = n()) %>%
  print_table_conditional()

4-digit: Very Few

Code
hbs_str_t223 %>%
  filter(nchar(coicop) == 6) %>%
  left_join(coicop, by = "coicop") %>%
  group_by(coicop, Coicop) %>%
  summarise(Nobs = n()) %>%
  print_table_conditional()

quantile

Code
hbs_str_t223 %>%
  left_join(quantile, by = "quantile") %>%
  group_by(quantile, Quantile) %>%
  summarise(Nobs = n()) %>%
  print_table_conditional()
quantile Quantile Nobs
QUINTILE1 First quintile 10822
QUINTILE2 Second quintile 10834
QUINTILE3 Third quintile 10842
QUINTILE4 Fourth quintile 10856
QUINTILE5 Fifth quintile 10849
UNK Unknown 59

geo

Code
hbs_str_t223 %>%
  left_join(geo, by = "geo") %>%
  group_by(geo, Geo) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  mutate(Geo = ifelse(geo == "DE", "Germany", Geo)) %>%
  mutate(Flag = gsub(" ", "-", str_to_lower(Geo)),
         Flag = paste0('<img src="../../bib/flags/vsmall/', Flag, '.png" alt="Flag">')) %>%
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

unit

Code
hbs_str_t223 %>%
  group_by(unit) %>%
  summarise(Nobs = n()) %>%
  print_table_conditional()
unit Nobs
PM 54262

time

Code
hbs_str_t223 %>%
  group_by(time) %>%
  summarise(Nobs = n()) %>%
  print_table_conditional()
time Nobs
1988 2710
1994 4880
1999 4449
2005 11102
2010 13712
2015 9854
2020 7555

France

Table

Code
hbs_str_t223 %>%
  left_join(coicop, by = "coicop") %>%
  filter(geo == "FR",
         substr(coicop, 1, 2) == "CP",
         coicop != "CP00",
         time %in% c("2020")) %>%
  select(-unit, -time) %>%
  select(-geo) %>%
  spread(quantile, values) %>%
  print_table_conditional()

Sum

Code
hbs_str_t211 %>%
  mutate(quantile = "TOTAL") %>%
  bind_rows(hbs_str_t223) %>%
  left_join(coicop, by = "coicop") %>%
  filter(geo == "FR",
         substr(coicop, 1, 2) == "CP",
         coicop != "CP00",
         time %in% c("2020")) %>%
  mutate(coicop_nchar = nchar(coicop)) %>%
  group_by(coicop_nchar, quantile) %>%
  summarise(Nobs = n(),
            sum = sum(values)) %>%
  print_table_conditional()
coicop_nchar quantile Nobs sum
4 QUINTILE1 12 1000
4 QUINTILE2 12 1000
4 QUINTILE3 12 1001
4 QUINTILE4 12 999
4 QUINTILE5 12 1001
4 TOTAL 12 1002
5 QUINTILE1 47 993
5 QUINTILE2 47 992
5 QUINTILE3 47 993
5 QUINTILE4 47 988
5 QUINTILE5 47 981
5 TOTAL 47 991
6 TOTAL 115 896

2-digit and 3-digit

Code
`table1` <- hbs_str_t211 %>%
  mutate(quantile = "TOTAL") %>%
  bind_rows(hbs_str_t223) %>%
  left_join(coicop, by = "coicop") %>%
  filter(geo == "FR",
         substr(coicop, 1, 2) == "CP",
         nchar(coicop) %in% c(4, 5),
         coicop != "CP00",
         time %in% c("2020")) %>%
  select(-unit, -time) %>%
  select(-geo) %>%
  spread(quantile, values)

`table1` %>%
  gt::gt() %>%
  gt::gtsave(filename = "hbs_str_t223_files/figure-html/table1-1.png")

`table1` %>%
  print_table_conditional()

Missing: CP091+CP092+CP093+CP094 = 61 et pas 66

2-digit

Code
`table1-2digit` <- hbs_str_t211 %>%
  mutate(quantile = "TOTAL") %>%
  bind_rows(hbs_str_t223) %>%
  left_join(coicop, by = "coicop") %>%
  filter(geo == "FR",
         substr(coicop, 1, 2) == "CP",
         nchar(coicop) == 4,
         coicop != "CP00",
         time %in% c("2020")) %>%
  select(-unit, -time) %>%
  select(-geo) %>%
  spread(quantile, values)

`table1-2digit` %>%
  gt::gt() %>%
  gt::gtsave(filename = "hbs_str_t223_files/figure-html/table1-2digit-1.png")

`table1-2digit` %>%
  print_table_conditional()
freq coicop Coicop QUINTILE1 QUINTILE2 QUINTILE3 QUINTILE4 QUINTILE5 TOTAL
A CP01 Food and non-alcoholic beverages 147 150 154 150 128 143
A CP02 Alcoholic beverages, tobacco and narcotics 35 30 28 24 20 25
A CP03 Clothing and footwear 43 37 38 39 41 40
A CP04 Housing, water, electricity, gas and other fuels 347 328 305 279 255 289
A CP05 Furnishings, household equipment and routine household maintenance 34 40 43 47 58 48
A CP06 Health 15 16 18 16 15 16
A CP07 Transport 102 113 121 139 149 132
A CP08 Communications 35 28 25 23 18 24
A CP09 Recreation and culture 66 66 72 76 89 77
A CP10 Education 8 4 3 4 9 6
A CP11 Restaurants and hotels 40 41 44 52 71 55
A CP12 Miscellaneous goods and services 128 147 150 150 148 147

3-digit

Code
FR_3digit_weights2020 <- hbs_str_t211 %>%
  mutate(quantile = "TOTAL") %>%
  bind_rows(hbs_str_t223) %>%
  filter(geo == "FR",
         substr(coicop, 1, 2) == "CP",
         nchar(coicop) == 5,
         coicop != "CP00",
         time %in% c("2020")) %>%
  select(-unit, -geo, -time)

dir.create("hbs_str_t223_files/data-RData")
do.call(save, list("FR_3digit_weights2020", file = "hbs_str_t223_files/data-RData/FR_3digit_weights2020.RData"))

FR_3digit_weights2020 %>%
  spread(quantile, values) %>%
  print_table_conditional()
Code
FR_3digit_weights2020 %>%
  spread(quantile, values) %>%
  gt::gt() %>%
  gt::gtsave(filename = "hbs_str_t223_files/figure-html/FR_3digit_weights2020-1.png")

France - Compare

2020, HBS

Code
hbs_str_t223 %>%
  filter(time == "2020",
         geo == "FR") %>%
  left_join(coicop, by = "coicop") %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(quantile, values) %>%
  select_if(~ n_distinct(.) > 1) %>%
  print_table_conditional

2015, HBS

All

Code
hbs_str_t223 %>%
  filter(time == "2015",
         geo == "FR") %>%
  left_join(coicop, by = "coicop") %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(quantile, values) %>%
  select_if(~ n_distinct(.) > 1) %>%
  print_table_conditional

2-digit

Code
hbs_str_t223 %>%
  filter(time == "2015",
         geo == "FR",
         nchar(coicop) == 4) %>%
  left_join(coicop, by = "coicop") %>%
  select_if(~ n_distinct(.) > 1) %>%
  spread(quantile, values) %>%
  select_if(~ n_distinct(.) > 1) %>%
  print_table_conditional
coicop Coicop QUINTILE1 QUINTILE2 QUINTILE3 QUINTILE4 QUINTILE5
CP01 Food and non-alcoholic beverages 147 150 154 150 128
CP02 Alcoholic beverages, tobacco and narcotics 35 30 28 24 20
CP03 Clothing and footwear 43 37 38 39 41
CP04 Housing, water, electricity, gas and other fuels 347 328 305 279 255
CP05 Furnishings, household equipment and routine household maintenance 34 40 43 47 58
CP06 Health 15 16 18 16 15
CP07 Transport 102 113 121 139 149
CP08 Communications 35 28 25 23 18
CP09 Recreation and culture 66 66 72 76 89
CP10 Education 8 4 3 4 9
CP11 Restaurants and hotels 40 41 44 52 71
CP12 Miscellaneous goods and services 128 147 150 150 148

France

Actual + Imputed

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2015",
         geo %in% c("FR")) %>%
  mutate(Coicop = factor(coicop, levels = c("CP042", "CP041"), labels = c("Loyers imputés (propriétaires)", "Loyers réels (locataires)"))) %>%
  ggplot + geom_col(aes(x = quantile, y = values/1000, fill = Coicop)) +
  theme_minimal() +
  xlab("Quintile") + ylab("Poids dans l'Indice des Prix") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.direction = "horizontal",
        legend.title = element_blank())

Tous

Code
hbs_str_t225 %>%
  rename(category = age) %>%
  mutate(type = "age") %>%
  bind_rows(hbs_str_t223 %>%
              rename(category = quantile) %>%
              mutate(type = "quantile")) %>%
  bind_rows(hbs_str_t226 %>%
              rename(category = deg_urb) %>%
              mutate(type = "deg_urb")) %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2015",
         geo %in% c("FR")) %>%
  mutate(Coicop = factor(coicop, levels = c("CP042", "CP041"), labels = c("Loyers imputés (propriétaires)", "Loyers réels (locataires)")),
         Category = factor(category, levels = c("Y_LT30", "Y30-44", "Y45-59", "Y_GE60",
                                                "DEG1", "DEG2", "DEG3",
                                                "QUINTILE1", "QUINTILE2", "QUINTILE3", "QUINTILE4", "QUINTILE5"),
                           labels = c("Moins de 30 ans", "De 30 à 44 ans", "De 45 à 59 ans", "Plus de 60 ans",
                                      "Villes", "Villes - peuplées\net banlieues", "Zones rurales",
                                      "1er", "2è", "3è", "4è", "5è")),
         Type = factor(type, levels = c("age", "deg_urb", "quantile"),
                       labels = c("Age", "Commune de résidence", "Cinquième"))) %>%
  ggplot + geom_col(aes(x = Category, y = values/1000, fill = Coicop)) +
  theme_minimal() +
  xlab("") + ylab("Poids dans l'Indice des Prix") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = "top",
        legend.direction = "horizontal",
        legend.title = element_blank(),
        axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) +
  facet_wrap(~ Type, scales = "free")

All quintiles

Sums

2-digit

Code
hbs_str_t223 %>%
  filter(time == "2020",
         substr(coicop, 1, 2) == "CP",
         nchar(coicop) == 4) %>%
  left_join(geo, by = "geo") %>%
  select_if(~ n_distinct(.) > 1) %>%
  group_by(quantile, geo, Geo) %>%
  summarise(values = sum(values)) %>%
  spread(quantile, values) %>%
  print_table_conditional
geo Geo QUINTILE1 QUINTILE2 QUINTILE3 QUINTILE4 QUINTILE5
AT Austria 1000 1001 998 1001 1001
BE Belgium 1001 999 999 998 1000
BG Bulgaria 999 1000 999 1000 999
CY Cyprus 1001 1000 1000 1000 1000
DE Germany 1000 1002 1000 1001 1001
DK Denmark 1001 999 1002 1000 1001
EE Estonia 1001 1000 1000 999 1001
EL Greece 999 1000 1001 999 1000
ES Spain 1000 999 1002 1000 1000
EU27_2020 European Union - 27 countries (from 2020) 1000 999 998 1000 1000
FI Finland 999 1000 1000 998 1000
FR France 1000 1000 1001 999 1001
HR Croatia 998 999 1000 1000 1000
HU Hungary 999 1000 1000 1000 999
IE Ireland 999 1000 1001 1000 1000
LT Lithuania 1001 1001 999 998 1001
LU Luxembourg 1001 1001 999 1000 1000
LV Latvia 999 1002 1001 1000 1000
ME Montenegro 1001 1000 999 1000 1001
MT Malta 1000 998 1002 1000 999
NL Netherlands 1000 999 1000 1000 999
PL Poland 1001 1000 1001 1001 1001
PT Portugal 1000 1001 1000 1000 999
RO Romania 1000 1001 999 999 1000
RS Serbia 999 999 1001 1000 1000
SI Slovenia 1000 1000 1000 1000 999
SK Slovakia 1001 1000 999 1000 1001
TR Türkiye 1000 999 999 999 1000

3-digit

Code
hbs_str_t223 %>%
  filter(time == "2020",
         substr(coicop, 1, 2) == "CP",
         nchar(coicop) == 5) %>%
  left_join(geo, by = "geo") %>%
  select_if(~ n_distinct(.) > 1) %>%
  group_by(quantile, geo, Geo) %>%
  summarise(values = sum(values)) %>%
  spread(quantile, values) %>%
  print_table_conditional
geo Geo QUINTILE1 QUINTILE2 QUINTILE3 QUINTILE4 QUINTILE5
AT Austria 996 1001 999 1001 1000
BE Belgium 1000 1002 999 1001 998
BG Bulgaria 1001 1002 998 1000 1000
CY Cyprus 999 995 996 997 997
DE Germany 994 992 992 995 986
DK Denmark 1000 998 999 998 1000
EE Estonia 980 982 984 986 988
EL Greece 997 999 1002 999 1000
ES Spain 1000 999 999 1000 999
FI Finland 989 987 985 976 974
FR France 993 992 993 988 981
HR Croatia 1000 998 997 1004 1000
HU Hungary 1000 1000 996 1000 999
IE Ireland 1002 1000 999 1000 1000
LT Lithuania 998 1002 1001 1000 1001
LU Luxembourg 1001 997 996 998 1001
LV Latvia 998 999 1001 998 1002
ME Montenegro 986 985 987 981 985
MT Malta 998 1004 997 1002 1001
NL Netherlands 1001 998 1000 1000 1001
PL Poland 999 999 1003 1001 1001
RS Serbia 998 998 999 1000 999
SI Slovenia 1002 997 996 1000 1001
SK Slovakia 998 997 1002 997 999
TR Türkiye 1000 1000 995 1004 998

CP041, CP042, CP041_042

2015

Germany, France, Spain

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2015",
         geo %in% c("ES", "FR", "DE")) %>%
  spread(coicop, values) %>%
  mutate(CP041_042 = CP041 + CP042) %>%
  gather(coicop, values, CP041, CP042, CP041_042) %>%
  mutate(quantile = substr(quantile, 9, 9) %>% as.numeric) %>%
  left_join(geo, by = "geo") %>%
  left_join(coicop, by = "coicop") %>%
  left_join(colors, by = c("Geo" = "country")) %>%
  mutate(Coicop = ifelse(coicop == "CP041_042", "Imputed rentals plus actual rentals", Coicop)) %>%
  ggplot + geom_line(aes(x = quantile, y = values/1000, color = color, linetype = Coicop)) +
  scale_color_identity() + theme_minimal() +
  geom_image(data = . %>%
               filter(quantile == 1) %>%
               mutate(image = paste0("../../icon/flag/round/", str_to_lower(gsub(" ", "-", Geo)), ".png")),
             aes(x = quantile, y = values/1000, image = image), asp = 1.5) +
  xlab("Quintile") + ylab("Weight in CPI") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = c(0.8, 0.9),
        legend.title = element_blank()) +
  scale_x_continuous(breaks = seq(0, 5, 1))

Netherlands, Austria, Greece

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2015",
         geo %in% c("EL", "NL", "AT")) %>%
  spread(coicop, values) %>%
  mutate(CP041_042 = CP041 + CP042) %>%
  gather(coicop, values, CP041, CP042, CP041_042) %>%
  mutate(quantile = substr(quantile, 9, 9) %>% as.numeric) %>%
  left_join(geo, by = "geo") %>%
  left_join(coicop, by = "coicop") %>%
  left_join(colors, by = c("Geo" = "country")) %>%
  mutate(Coicop = ifelse(coicop == "CP041_042", "Imputed rentals plus actual rentals", Coicop)) %>%
  ggplot + geom_line(aes(x = quantile, y = values/1000, color = color, linetype = Coicop)) +
  scale_color_identity() + theme_minimal() +
  geom_image(data = . %>%
               filter(quantile == 1) %>%
               mutate(image = paste0("../../icon/flag/round/", str_to_lower(gsub(" ", "-", Geo)), ".png")),
             aes(x = quantile, y = values/1000, image = image), asp = 1.5) +
  xlab("Quintile") + ylab("Weight in CPI") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = c(0.8, 0.9),
        legend.title = element_blank()) +
  scale_x_continuous(breaks = seq(0, 5, 1))

CP041, CP042

2015

All

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2020") %>%
  left_join(geo, by = "geo") %>%
  spread(quantile, values) %>%
  select_if(~ n_distinct(.) > 1) %>%
  arrange(Geo) %>%
  print_table_conditional

Germany, France, Spain

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2015",
         geo %in% c("ES", "FR", "DE")) %>%
  mutate(quantile = substr(quantile, 9, 9) %>% as.numeric) %>%
  left_join(geo, by = "geo") %>%
  left_join(coicop, by = "coicop") %>%
  left_join(colors, by = c("Geo" = "country")) %>%
  ggplot + geom_line(aes(x = quantile, y = values/1000, color = color, linetype = Coicop)) +
  scale_color_identity() + theme_minimal() +
  geom_image(data = . %>%
               filter(quantile == 1) %>%
               mutate(image = paste0("../../icon/flag/round/", str_to_lower(gsub(" ", "-", Geo)), ".png")),
             aes(x = quantile, y = values/1000, image = image), asp = 1.5) +
  xlab("Quintile") + ylab("Weight in CPI") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = c(0.85, 0.85),
        legend.title = element_blank()) +
  scale_x_continuous(breaks = seq(0, 5, 1))

Netherlands, Austria, Greece

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2015",
         geo %in% c("EL", "NL", "AT")) %>%
  mutate(quantile = substr(quantile, 9, 9) %>% as.numeric) %>%
  left_join(geo, by = "geo") %>%
  left_join(coicop, by = "coicop") %>%
  left_join(colors, by = c("Geo" = "country")) %>%
  ggplot + geom_line(aes(x = quantile, y = values/1000, color = color, linetype = Coicop)) +
  scale_color_identity() + theme_minimal() +
  geom_image(data = . %>%
               filter(quantile == 1) %>%
               mutate(image = paste0("../../icon/flag/round/", str_to_lower(gsub(" ", "-", Geo)), ".png")),
             aes(x = quantile, y = values/1000, image = image), asp = 1.5) +
  xlab("Quintile") + ylab("Weight in CPI") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = c(0.8, 0.8),
        legend.title = element_blank()) +
  scale_x_continuous(breaks = seq(0, 5, 1))

2020

All

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2020") %>%
  left_join(geo, by = "geo") %>%
  spread(quantile, values) %>%
  select_if(~ n_distinct(.) > 1) %>%
  arrange(Geo) %>%
  print_table_conditional

Germany, France, Spain

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2020",
         geo %in% c("ES", "FR", "DE")) %>%
  mutate(quantile = substr(quantile, 9, 9) %>% as.numeric) %>%
  left_join(geo, by = "geo") %>%
  left_join(coicop, by = "coicop") %>%
  left_join(colors, by = c("Geo" = "country")) %>%
  ggplot + geom_line(aes(x = quantile, y = values/1000, color = color, linetype = Coicop)) +
  scale_color_identity() + theme_minimal() +
  geom_image(data = . %>%
               filter(quantile == 1) %>%
               mutate(image = paste0("../../icon/flag/round/", str_to_lower(gsub(" ", "-", Geo)), ".png")),
             aes(x = quantile, y = values/1000, image = image), asp = 1.5) +
  xlab("Quintile") + ylab("Weight in CPI") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = c(0.8, 0.8),
        legend.title = element_blank()) +
  scale_x_continuous(breaks = seq(0, 5, 1))

Netherlands, Austria, Greece

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP041", "CP042"),
         time == "2020",
         geo %in% c("EL", "NL", "AT")) %>%
  mutate(quantile = substr(quantile, 9, 9) %>% as.numeric) %>%
  left_join(geo, by = "geo") %>%
  left_join(coicop, by = "coicop") %>%
  left_join(colors, by = c("Geo" = "country")) %>%
  ggplot + geom_line(aes(x = quantile, y = values/1000, color = color, linetype = Coicop)) +
  scale_color_identity() + theme_minimal() +
  geom_image(data = . %>%
               filter(quantile == 1) %>%
               mutate(image = paste0("../../icon/flag/round/", str_to_lower(gsub(" ", "-", Geo)), ".png")),
             aes(x = quantile, y = values/1000, image = image), asp = 1.5) +
  xlab("Quintile") + ylab("Weight in CPI") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 5),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = c(0.85, 0.85),
        legend.title = element_blank()) +
  scale_x_continuous(breaks = seq(0, 5, 1))

CP011, CP012

2015

All

Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP011", "CP012"),
         time == "2020") %>%
  left_join(geo, by = "geo") %>%
  spread(quantile, values) %>%
  select_if(~ n_distinct(.) > 1) %>%
  arrange(Geo) %>%
  print_table_conditional

Germany, France, Spain

All
Code
hbs_str_t223 %>%
  filter(coicop %in% c("CP011", "CP01"),
         time == "2015",
         geo %in% c("ES", "FR", "DE")) %>%
  mutate(quantile = substr(quantile, 9, 9) %>% as.numeric) %>%
  left_join(geo, by = "geo") %>%
  left_join(coicop, by = "coicop") %>%
  left_join(colors, by = c("Geo" = "country")) %>%
  ggplot + geom_line(aes(x = quantile, y = values/1000, color = color, linetype = Coicop)) +
  scale_color_identity() + theme_minimal() +
  geom_image(data = . %>%
               filter(quantile == 2) %>%
               mutate(image = paste0("../../icon/flag/round/", str_to_lower(gsub(" ", "-", Geo)), ".png")),
             aes(x = quantile, y = values/1000, image = image), asp = 1.5) +
  xlab("Quintile") + ylab("Weight in CPI") +
  scale_y_continuous(breaks = 0.01*seq(-30, 50, 1),
                     labels = percent_format(accuracy = 1)) +
  theme(legend.position = c(0.75, 0.85),
        legend.title = element_blank()) +
  scale_x_continuous(breaks = seq(0, 5, 1))