library(csodata)
library(tidyverse)
library(knitr)
library(kableExtra)
library(ggplot2)
library(lubridate)
library(ggrepel)
library(zoo)
library(patchwork)
library(Hmisc)
library(formattable)
library(scales)

#Load

#Load

EIHC06 <- cso_get_data("EIHC06")
EIHC06 <- EIHC06 %>%
  pivot_longer(!1:3, names_to = "year_month")
EIHC06 <- EIHC06 %>%
  filter(Statistic=="Contribution to CPI percentage change in last 12 months")
EIHC06$Decile_Nr <- extract_numeric(EIHC06$Income.Deciles)

EIHC06A<- EIHC06 %>%
  filter(COICOP.Division=="All Items")%>%
  filter(Income.Deciles=="All deciles")

EIHC06B<- EIHC06 %>%
  filter(COICOP.Division!="All Items")%>%
  filter(Income.Deciles!="All deciles")

Contribution to Estimated Inflation

Income Decile & COICOP

HeatMap<-ggplot(data=EIHC06B, mapping = aes(x = Income.Deciles, y = COICOP.Division, fill = value))+
  geom_tile()+
  xlab(label = "Income Deciles")+
  theme(axis.text.x = element_text(angle = 90, hjust = 1))+
  theme(legend.position = "bottom")+
  scale_fill_gradient(name = "Contribution to Inflation",
                      low = "#F9F9FA",
                      high = "#010874")

HeatMap + facet_wrap(~year_month,ncol=1)