.chart-shim {
      overflow: auto;
    }
ale
month <- month(tail(mom_dt$Dates,1))
cpi_year <- mom_dt %>% 
  select("Dates","All Items") %>% 
  mutate(across(.cols = -1, .fns = ~tstools::acum_p(.x,month))) %>% 
  tail(1) %>% 
  select(2) %>% 
  round(1)

core_year <- mom_dt %>% 
  select("Dates","Core CPI") %>% 
  mutate(across(.cols = -1, .fns = ~tstools::acum_p(.x,month))) %>% 
  tail(1) %>% 
  select(2) %>% 
  round(1)

texto1 <- c("MoM","MoM","MoM","MoM","YoY","YoY","YoY","YoY","Ytd","Ytd")
texto2 <- c("Head", "Consensus", "Core", "Consensus", "Head", 
           "Consensus", "Core", "Consensus", "Head","Core")
valor <- c(round(tail(mom_dt$`All Items`,1),1),
          0.2,
          round(tail(mom_dt$`Core CPI`,1),1),
          0.3,
          round(tail(yoy_dt$`All Items`,1),1),
          3.2,
          round(tail(yoy_dt$`Core CPI`,1),1),
          3.8,
          as.numeric(cpi_year),
          as.numeric(core_year))

Tab_test <-  tibble(texto1,texto2,valor)

gt_side <- gt(Tab_test, groupname_col = "texto1", rowname_col = "texto2") %>%
  # Title:
  tab_header(title = format(tail(mom_dt$Dates,1), "%B %Y") ) %>%
  tab_options(heading.align = "left", heading.title.font.size = px(20), 
              table.border.top.color = "#DEE5EA") %>%
  tab_style( style = list( cell_text(color = "#DEE5EA") ),
             locations = cells_column_labels() ) %>%
  # General options:
  tab_options(
    column_labels.font.size = px(0),
    heading.border.bottom.color = "#DEE5EA",
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "#DEE5EA",
    column_labels.border.top.color = "#DEE5EA",
    column_labels.border.bottom.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "black",
    table_body.hlines.color = "#DEE5EA",
    table.border.bottom.width = px(3),
    table.font.size = 25,
    table.background.color = "#DEE5EA") %>%
  tab_style(locations = cells_body(rows = c(1,3,5,7,9,10)),
            style = list(cell_text(weight = "bold"))) %>% 
  tab_style(locations = cells_stub(rows = c(1,3,5,7,9,10)),
            style = list(cell_text(weight = "bold"))) %>% 
  tab_style(locations = cells_body(rows = c(2,4,6,8)),
            style = list(cell_text(size = px(18), style = "italic"))) %>% 
  tab_style(locations = cells_stub(rows = c(2,4,6,8)),
            style = list(cell_text(size = px(18), style = "italic"))) %>% 
  tab_style(style = cell_text(style = "italic", weight = "bold"),
            locations = list(cells_row_groups(),cells_column_labels(everything()))) %>% 
  tab_style(locations = cells_body(rows = 1),
            style = list(cell_text(color = 
                                     ifelse(valor[1]>valor[2],"#D3293D","#3B9C28")))) %>% 
  tab_style(locations = cells_stub(rows = 1),
            style = list(cell_text(color = 
                                     ifelse(valor[1]>valor[2],"#D3293D","#3B9C28")))) %>% 
  tab_style(locations = cells_body(rows = 3),
            style = list(cell_text(color = 
                                     ifelse(valor[3]>valor[4],"#D3293D","#3B9C28")))) %>% 
  tab_style(locations = cells_stub(rows = 3),
            style = list(cell_text(color = 
                                     ifelse(valor[3]>valor[4],"#D3293D","#3B9C28")))) %>% 
  tab_style(locations = cells_body(rows = 5),
            style = list(cell_text(color = 
                                     ifelse(valor[5]>valor[6],"#D3293D","#3B9C28")))) %>% 
  tab_style(locations = cells_stub(rows = 5),
            style = list(cell_text(color = 
                                     ifelse(valor[5]>valor[6],"#D3293D","#3B9C28")))) %>% 
  tab_style(locations = cells_body(rows = 7),
            style = list(cell_text(color = 
                                     ifelse(valor[7]>valor[8],"#D3293D","#3B9C28")))) %>% 
  tab_style(locations = cells_stub(rows = 7),
            style = list(cell_text(color = 
                                     ifelse(valor[7]>valor[8],"#D3293D","#3B9C28"))))

gt_side

ale


Column {.tabset}
-----------------------------------------------------------------------

### Overview MoM
gt(Tab_1.1) %>%
    # Title:
    tab_style( style = list( cell_text(weight = "bold") ),
               locations = cells_column_labels(everything()) ) %>% 
    tab_style( style = list( cell_text(color = "#FFFFFF") ),
               locations = cells_column_labels(5) ) %>%
    tab_options(heading.align = "left", table.border.top.color = "white",
                table.border.top.width = px(3)) %>%
    # General options:
    tab_options(
      column_labels.border.top.color = "black",
      column_labels.border.top.width = px(3),
      column_labels.border.bottom.color = "black",
      table.border.bottom.color = "white",
      table_body.hlines.color = "white",
      table.border.bottom.width = px(3),
      table.font.size = "small",
      heading.title.font.size = 20,
      heading.subtitle.font.size = 12,
      data_row.padding = px(2) ) %>%
    cols_align(2:8,align = "right") %>%
    cols_width(`Items` ~ px(280), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
               `bps_m` ~ px(40), `m1_c` ~ px(60),`m2_c` ~ px(60),
               `m3_c` ~ px(60)) %>%
    tab_style(locations = cells_body(columns = c(4,8)),
              style = list(cell_text(weight = "bold"))) %>%
    # Spanners:
    tab_spanner(label = "MoM sa", columns = 2:4) %>%
    tab_spanner(label = "MoM Contribuitions", columns = 6:8) %>%
    cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
               `m1_c` = names_tab[1], `m2_c` = names_tab[2], 
               `m3_c` = names_tab[3]) %>%
    tab_style(locations = cells_column_spanners(everything()),
              style = list(cell_text(weight = "bold"))) %>% 
    # Main rows:
    tab_style(locations = cells_body(rows = c(1,2,5,10)),
              style = list(cell_text(weight = "bold"),
                           cell_fill(color = "#E5E5E2"))) %>%
    # Minor 1 rows:
    tab_style(locations = cells_body(rows = c(3,4,6,8,11,22)),
              style = list(cell_fill(color = "#F5F5F5"))) %>%
    tab_style(locations = cells_body(rows = c(3,4,6,8,11,22), columns = 1),
              style = list(cell_text(indent = px(10)))) %>%      
    # Minor 2 rows:
    tab_style(locations = cells_body(rows = c(7,9,12,13,14,17,18,19,20,21,
                                              23,24,25,26,27,29,30,31),
                                     columns = 1),
              style = list(cell_text(indent = px(20)))) %>%
    # Minor 3 rows:
    tab_style(locations = cells_body(rows = c(15,16,28), columns = 1),
              style = list(cell_text(indent = px(30)))) %>%
    # Footnote:
    tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) %>% 
  gt_fa_rank_change(column = 5, palette = c("#D42940", "grey","#1b7837"),
                    font_color = "match", fa_type = "caret")
  

ale

### Overview YoY
gt(Tab_1.2) %>%
    # Title:
    tab_style( style = list( cell_text(weight = "bold") ),
               locations = cells_column_labels(everything()) ) %>% 
    tab_style( style = list( cell_text(color = "#FFFFFF") ),
               locations = cells_column_labels(5) ) %>%
    tab_options(heading.align = "left", table.border.top.color = "white",
                table.border.top.width = px(3)) %>%
    # General options:
    tab_options(
      column_labels.border.top.color = "black",
      column_labels.border.top.width = px(3),
      column_labels.border.bottom.color = "black",
      table.border.bottom.color = "white",
      table_body.hlines.color = "white",
      table.border.bottom.width = px(3),
      table.font.size = "small",
      heading.title.font.size = 20,
      heading.subtitle.font.size = 12,
      data_row.padding = px(2) ) %>%
    cols_align(2:8,align = "right") %>%
    cols_width(`Items` ~ px(280), `y1` ~ px(60),`y2` ~ px(60),`y3` ~ px(60),
               `bps_y` ~ px(40), `y1_c` ~ px(60),`y2_c` ~ px(60),
               `y3_c` ~ px(60)) %>%
    tab_style(locations = cells_body(columns = c(4,8)),
              style = list(cell_text(weight = "bold"))) %>%
    # Spanners:
    tab_spanner(label = "YoY nsa", columns = 2:4) %>%
    tab_spanner(label = "YoY Contribuitions", columns = 6:8) %>%
    cols_label(`y1` = names_tab[1], `y2` = names_tab[2], 
               `y3` = names_tab[3], `y1_c` = names_tab[1], `y2_c` = names_tab[2], 
               `y3_c` = names_tab[3]) %>%
    tab_style(locations = cells_column_spanners(everything()),
              style = list(cell_text(weight = "bold"))) %>% 
    # Main rows:
    tab_style(locations = cells_body(rows = c(1,2,5,10)),
              style = list(cell_text(weight = "bold"),
                           cell_fill(color = "#E5E5E2"))) %>%
    # Minor 1 rows:
    tab_style(locations = cells_body(rows = c(3,4,6,8,11,22)),
              style = list(cell_fill(color = "#F5F5F5"))) %>%
    tab_style(locations = cells_body(rows = c(3,4,6,8,11,22), columns = 1),
              style = list(cell_text(indent = px(10)))) %>%      
    # Minor 2 rows:
    tab_style(locations = cells_body(rows = c(7,9,12,13,14,17,18,19,20,21,
                                              23,24,25,26,27,29,30,31),
                                     columns = 1),
              style = list(cell_text(indent = px(20)))) %>%
    # Minor 3 rows:
    tab_style(locations = cells_body(rows = c(15,16,28), columns = 1),
              style = list(cell_text(indent = px(30)))) %>%
    # Footnote:
    tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) %>% 
  gt_fa_rank_change(column = 5, palette = c("#D42940", "grey","#1b7837"),
                    font_color = "match", fa_type = "caret")


ale


### Food
d1 <- nrow(Tab_1.3_m)
d2 <- nrow(Tab_1.3)

rbPal <- colorRampPalette(c("#3EB342","#E9E961", "#E45B5B"))
heat_color <- rbPal(100)[as.numeric(cut(Tab_1.3$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.3$cg_3[(d1+2):d2], breaks = 100))]

gt_1.3 <- gt(Tab_1.3, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.3),align = "right") %>%
  cols_width(`Items` ~ px(250), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.3)/2)){
  gt_1.3 <- tab_style(gt_1.3, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.3 <- tab_style(gt_1.3, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.3)/2) ))
}

gt_1.3  


ale

### Housing
d1 <- nrow(Tab_1.4_m)
d2 <- nrow(Tab_1.4)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.4$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.4$cg_3[(d1+2):d2], breaks = 100))]

gt_1.4 <- gt(Tab_1.4, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.4),align = "right") %>%
  cols_width(`Items` ~ px(310), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.4)/2)){
  gt_1.4 <- tab_style(gt_1.4, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.4 <- tab_style(gt_1.4, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.4)/2) ))
}

gt_1.4  

Apparel

d1 <- nrow(Tab_1.5_m)
d2 <- nrow(Tab_1.5)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.5$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.5$cg_3[(d1+2):d2], breaks = 100))]

gt_1.5 <- gt(Tab_1.5, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.5),align = "right") %>%
  cols_width(`Items` ~ px(250), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.5)/2)){
  gt_1.5 <- tab_style(gt_1.5, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.5 <- tab_style(gt_1.5, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.5)/2) ))
}

gt_1.5  

ale

### Transportation
d1 <- nrow(Tab_1.6_m)
d2 <- nrow(Tab_1.6)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.6$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.6$cg_3[(d1+2):d2], breaks = 100))]

gt_1.6 <- gt(Tab_1.6, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.6),align = "right") %>%
  cols_width(`Items` ~ px(310), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.6)/2)){
  gt_1.6 <- tab_style(gt_1.6, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.6 <- tab_style(gt_1.6, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.6)/2) ))
}

gt_1.6  


ale

### Medical care
d1 <- nrow(Tab_1.7_m)
d2 <- nrow(Tab_1.7)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.7$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.7$cg_3[(d1+2):d2], breaks = 100))]

gt_1.7 <- gt(Tab_1.7, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.7),align = "right") %>%
  cols_width(`Items` ~ px(250), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.7)/2)){
  gt_1.7 <- tab_style(gt_1.7, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.7 <- tab_style(gt_1.7, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.7)/2) ))
}

gt_1.7  

ale

### Recreation
d1 <- nrow(Tab_1.8_m)
d2 <- nrow(Tab_1.8)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.8$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.8$cg_3[(d1+2):d2], breaks = 100))]

gt_1.8 <- gt(Tab_1.8, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.8),align = "right") %>%
  cols_width(`Items` ~ px(250), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.8)/2)){
  gt_1.8 <- tab_style(gt_1.8, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.8 <- tab_style(gt_1.8, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.8)/2) ))
}

gt_1.8  

ale

### Education and Comm.
d1 <- nrow(Tab_1.9_m)
d2 <- nrow(Tab_1.9)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.9$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.9$cg_3[(d1+2):d2], breaks = 100))]

gt_1.9 <- gt(Tab_1.9, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.9),align = "right") %>%
  cols_width(`Items` ~ px(310), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.9)/2)){
  gt_1.9 <- tab_style(gt_1.9, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.9 <- tab_style(gt_1.9, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.9)/2) ))
}

gt_1.9  

ale



### Other goods and services
d1 <- nrow(Tab_1.10_m)
d2 <- nrow(Tab_1.10)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.10$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.10$cg_3[(d1+2):d2], breaks = 100))]

gt_1.10 <- gt(Tab_1.10, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.10),align = "right") %>%
  cols_width(`Items` ~ px(250), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.10)/2)){
  gt_1.10 <- tab_style(gt_1.10, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.10 <- tab_style(gt_1.10, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.10)/2) ))
}

gt_1.10  

ale

### Energy
d1 <- nrow(Tab_1.11_m)
d2 <- nrow(Tab_1.11)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.11$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.11$cg_3[(d1+2):d2], breaks = 100))]

gt_1.11 <- gt(Tab_1.11, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.11),align = "right") %>%
  cols_width(`Items` ~ px(250), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.11)/2)){
  gt_1.11 <- tab_style(gt_1.11, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.11 <- tab_style(gt_1.11, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.11)/2) ))
}

gt_1.11
  
ale

### Goods
d1 <- nrow(Tab_1.12_m)
d2 <- nrow(Tab_1.12)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.12$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.12$cg_3[(d1+2):d2], breaks = 100))]

gt_1.12 <- gt(Tab_1.12, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.12),align = "right") %>%
  cols_width(`Items` ~ px(250), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.12)/2)){
  gt_1.12 <- tab_style(gt_1.12, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.12 <- tab_style(gt_1.12, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.12)/2) ))
}

gt_1.12

ale

### Services
d1 <- nrow(Tab_1.13_m)
d2 <- nrow(Tab_1.13)

heat_color <- rbPal(100)[as.numeric(cut(Tab_1.13$cg_3[2:d1], breaks = 100))]
heat_color2 <- rbPal(100)[as.numeric(cut(Tab_1.13$cg_3[(d1+2):d2], breaks = 100))]

gt_1.13 <- gt(Tab_1.13, groupname_col = "Type", rowname_col = "Items") %>%
  # Title:
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(3:ncol(Tab_1.13),align = "right") %>%
  cols_width(`Items` ~ px(310), `m1` ~ px(60), `m2` ~ px(60), `m3` ~ px(60), 
             `cg_1` ~ px(60), `cg_2` ~ px(60),`cg_3` ~ px(60),`ca_1` ~ px(60),
             `ca_2` ~ px(60),`ca_3` ~ px(60)) %>%
  tab_style(locations = cells_body(columns = c(5,8,11)),
            style = list(cell_text(weight = "bold"))) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Spanners:
  tab_spanner(label = "Price change", columns = 3:5) %>%
  tab_spanner(label = "Group Impact", columns = 6:8) %>%
  tab_spanner(label = "CPI Impact", columns = 9:11) %>%
  cols_label(`m1` = names_tab[1], `m2` = names_tab[2], `m3` = names_tab[3],
             `cg_1` = names_tab[1], `cg_2` = names_tab[2], 
             `cg_3` = names_tab[3], `ca_1` = names_tab[1], 
             `ca_2` = names_tab[2], `ca_3` = names_tab[3]) %>%
  tab_style(locations = cells_column_spanners(everything()),
            style = list(cell_text(weight = "bold"))) %>% 
  # Main rows:
  tab_style(locations = cells_body(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  tab_style(locations = cells_stub(rows = c(1,d1+1)),
            style = list(cell_text(weight = "bold"),
                         cell_fill(color = "#E5E5E2"))) %>%
  # Minor rows:
  tab_style(locations = cells_stub(rows = c(2:d1,(d1+2):d2)),
            style = list(cell_text(indent = px(10)))) %>%
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 

# Heatmap
for(i in 2:(nrow(Tab_1.13)/2)){
  gt_1.13 <- tab_style(gt_1.13, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color[i-1])),
                      locations = cells_body(columns = 8, rows = i)) 
  gt_1.13 <- tab_style(gt_1.13, style = list(cell_text(weight = "bold"), cell_fill(color = heat_color2[i-1])),
                      locations = cells_body(columns = 8, rows = i + (nrow(Tab_1.13)/2) ))
}

gt_1.13

ale


###  
P_1.1

ale


### 
P_1.2

ale


Core {data-icon="fa-chevron-right"}
=====================================

Column {.sidebar}
-----------------------------------------------------------------------

### 
gt_side

ale

Column {.tabset}
-----------------------------------------------------------------------

### Overview - MoM sa
heat_color <- list()
for(i in 1:nrow(Tab_2.1)){
  heat_color[[i]] <-  rbPal(100)[cut(as.numeric(Tab_2.1[i,-1]), 
                                     breaks = 100)]
}

colnames(Tab_2.1) <- c(" ", 
                       format(tail(mom_dt$Dates,ncol(Tab_2.2)-1), "%b/%y") )

gt_2.1 <- gt(Tab_2.1) %>%
  # Title:
  tab_header( title = md("**US CPI core measures - MoM sa**"), 
              subtitle = format(tail(mom_dt$Dates,1), "%b/%y") ) %>%
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(2:ncol(Tab_2.1),align = "right") %>%
  cols_width(everything() ~ px(50)) %>% 
  cols_width(1 ~ px(250)) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 


for(j in 1:nrow(Tab_2.1)){
  for(i in 2:ncol(Tab_2.1)){
    gt_2.1 <- tab_style(gt_2.1, 
                        style = list(cell_text(weight = "bold"), 
                                     cell_fill(color = heat_color[[j]][i-1])), 
                        locations = cells_body(columns = i,  rows = j))
  }
}

gt_2.1


ale

### Overview - YoY
heat_color <- list()
for(i in 1:nrow(Tab_2.2)){
  heat_color[[i]] <-  rbPal(100)[cut(as.numeric(Tab_2.2[i,-1]), 
                                     breaks = 100)]
}

colnames(Tab_2.2) <- c(" ", 
                       format(tail(mom_dt$Dates,ncol(Tab_2.2)-1), "%b/%y") )

gt_2.2 <- gt(Tab_2.2) %>%
  # Title:
  tab_header( title = md("**US CPI core measures - YoY nsa**"), 
              subtitle = format(tail(mom_dt$Dates,1), "%b/%y") ) %>%
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(2:ncol(Tab_2.2),align = "right") %>%
  cols_width(everything() ~ px(50)) %>% 
  cols_width(1 ~ px(250)) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 


for(j in 1:nrow(Tab_2.2)){
  for(i in 2:ncol(Tab_2.2)){
    gt_2.2 <- tab_style(gt_2.2, 
                        style = list(cell_text(weight = "bold"), 
                                     cell_fill(color = heat_color[[j]][i-1])), 
                        locations = cells_body(columns = i,  rows = j))
  }
}

gt_2.2


ale

### Overview - SAAR
heat_color <- list()
for(i in 1:nrow(Tab_2.3)){
  heat_color[[i]] <-  rbPal(100)[cut(as.numeric(Tab_2.3[i,-1]), 
                                     breaks = 100)]
}

colnames(Tab_2.3) <- c(" ", 
                       format(tail(mom_dt$Dates,ncol(Tab_2.3)-1), "%b/%y") )

gt_2.3 <- gt(Tab_2.3) %>%
  # Title:
  tab_header( title = md("**US CPI core measures - SAAR MM3**"), 
              subtitle = format(tail(mom_dt$Dates,1), "%b/%y") ) %>%
  tab_style( style = list( cell_text(weight = "bold") ),
             locations = cells_column_labels(everything()) ) %>% 
  tab_options(heading.align = "left", table.border.top.color = "white",
              table.border.top.width = px(3)) %>%
  # General options:
  tab_options(
    stub.border.width = px(0),
    row_group.border.top.color = "black",
    row_group.border.bottom.color = "white",
    column_labels.border.top.color = "black",
    column_labels.border.top.width = px(3),
    column_labels.border.bottom.color = "black",
    table.border.bottom.color = "white",
    table_body.hlines.color = "white",
    table.border.bottom.width = px(3),
    table.font.size = "small",
    heading.title.font.size = 20,
    heading.subtitle.font.size = 12,
    data_row.padding = px(2) ) %>%
  cols_align(2:ncol(Tab_2.3),align = "right") %>%
  cols_width(everything() ~ px(50)) %>% 
  cols_width(1 ~ px(250)) %>%
  tab_style(
    style = cell_text(color = "black", weight = "bold"),
    locations = list(
      cells_row_groups(),
      cells_column_labels(everything()))) %>% 
  # Footnote:
  tab_source_note(md("**Table**: ARX Macro | **Data**: BLS")) 


for(j in 1:nrow(Tab_2.3)){
  for(i in 2:ncol(Tab_2.3)){
    gt_2.3 <- tab_style(gt_2.3, 
                        style = list(cell_text(weight = "bold"), 
                                     cell_fill(color = heat_color[[j]][i-1])), 
                        locations = cells_body(columns = i,  rows = j))
  }
}

gt_2.3


ale


### Core CPI
P_2.1

ale

### Core Services
P_2.2

ale

### Core Goods
P_2.3

ale

### Core less shelter
P_2.4

ale

### Core less shelter and used cars
P_2.5

ale

### CPI ex-food
P_2.6

ale

### CPI ex-energy
P_2.7

ale

### Double weighting
P_2.8

ale

### Trimmed mean
P_2.9

ale

### P50
P_2.10

ale

### Durables
P_2.11

ale

### Nondurables
P_2.12

ale

### Nondurables less food
P_2.13

ale

### 
P_2.14

ale

### 
P_2.15

ale

YoY Contribution {data-icon="fa-chevron-right"}
=====================================

Column {.sidebar}
-----------------------------------------------------------------------

### 
gt_side

ale

Column {.tabset}
-----------------------------------------------------------------------


### CPI 1
P_3.1

ale

### Food
P_3.2

ale

### Energy
P_3.3

ale

### Core goods
P_3.4

ale

### Core services
P_3.5

ale

### CPI 2
P_3.6

ale

MoM Contribution {data-icon="fa-chevron-right"}
=====================================

Column {.sidebar}
-----------------------------------------------------------------------

### 
gt_side

ale

Column {.tabset}
-----------------------------------------------------------------------

### Main CPI composition
P_4.1

ale

### Food
P_4.2

ale

### Energy
P_4.3

ale

### Core goods
P_4.4

ale

### Core services
P_4.5

ale

### Alternative CPI composition
P_4.6

ale



Diffusion {data-icon="fa-chevron-right"}
=====================================

Column {.sidebar}
-----------------------------------------------------------------------

### 
gt_side

ale


Column {.tabset}
-----------------------------------------------------------------------

### Overview SAAR
heat_color <- list()
for(i in 1:nrow(Tab_5.1)){
  heat_color[[i]] <-  rbPal(100)[cut(as.numeric(Tab_5.1[i,-c(1:2)]), 
                                     breaks = 100)]
}

colnames(Tab_5.1) <- c("Type", "Items", 
                       format(tail(mom_dt$Dates,ncol(Tab_5.1)-2), "%b/%y") )

gt_5.1 <- gt(Tab_5.1, groupname_col = "Type", rowname_col = "Items") %>%
    # Title:
    tab_style( style = list( cell_text(weight = "bold") ),
               locations = cells_column_labels(everything()) ) %>% 
    tab_options(heading.align = "left", table.border.top.color = "white",
                table.border.top.width = px(3)) %>%
    # General options:
    tab_options(
      stub.border.width = px(0),
      row_group.border.top.color = "black",
      row_group.border.bottom.color = "white",
      column_labels.border.top.color = "black",
      column_labels.border.top.width = px(3),
      column_labels.border.bottom.color = "black",
      table.border.bottom.color = "white",
      table_body.hlines.color = "white",
      table.border.bottom.width = px(3),
      table.font.size = "small",
      heading.title.font.size = 20,
      heading.subtitle.font.size = 12,
      data_row.padding = px(2) ) %>%
    cols_align(3:ncol(Tab_5.1),align = "right") %>%
    cols_width(everything() ~ px(50)) %>%
    cols_width(`Items` ~ px(200)) %>%
    tab_style(style = cell_text(weight = "bold"), locations = 
                list(cells_row_groups(),cells_column_labels(everything()))) %>% 
    # Footnote:
    tab_source_note(md("**Table**: ARX Macro | **Data**: BLS"))

for(j in 1:nrow(Tab_5.1)){
  for(i in 3:ncol(Tab_5.1)){
    gt_5.1 <- tab_style(gt_5.1, 
                        style = list(cell_text(weight = "bold"), 
                                     cell_fill(color = heat_color[[j]][i-2])), 
                        locations = cells_body(columns = i,  rows = j))
  }
}

gt_5.1


ale

### Overview YoY
heat_color <- list()
for(i in 1:nrow(Tab_5.2)){
  heat_color[[i]] <-  rbPal(100)[cut(as.numeric(Tab_5.2[i,-c(1:2)]), 
                                     breaks = 100)]
}

colnames(Tab_5.2) <- c("Type", "Items", 
                       format(tail(mom_dt$Dates,ncol(Tab_5.2)-2), "%b/%y") )

gt_5.2 <- gt(Tab_5.2, groupname_col = "Type", rowname_col = "Items") %>%
    # Title:
    tab_style( style = list( cell_text(weight = "bold") ),
               locations = cells_column_labels(everything()) ) %>% 
    tab_options(heading.align = "left", table.border.top.color = "white",
                table.border.top.width = px(3)) %>%
    # General options:
    tab_options(
      stub.border.width = px(0),
      row_group.border.top.color = "black",
      row_group.border.bottom.color = "white",
      column_labels.border.top.color = "black",
      column_labels.border.top.width = px(3),
      column_labels.border.bottom.color = "black",
      table.border.bottom.color = "white",
      table_body.hlines.color = "white",
      table.border.bottom.width = px(3),
      table.font.size = "small",
      heading.title.font.size = 20,
      heading.subtitle.font.size = 12,
      data_row.padding = px(2) ) %>%
    cols_align(3:ncol(Tab_5.2),align = "right") %>%
    cols_width(everything() ~ px(50)) %>%
    cols_width(`Items` ~ px(200)) %>%
    tab_style(style = cell_text(weight = "bold"), locations = 
                list(cells_row_groups(),cells_column_labels(everything()))) %>% 
    # Footnote:
    tab_source_note(md("**Table**: ARX Macro | **Data**: BLS"))

for(j in 1:nrow(Tab_5.2)){
  for(i in 3:ncol(Tab_5.2)){
    gt_5.2 <- tab_style(gt_5.2, 
                        style = list(cell_text(weight = "bold"), 
                                     cell_fill(color = heat_color[[j]][i-2])), 
                        locations = cells_body(columns = i,  rows = j))
  }
}

gt_5.2


ale


### SAAR Composition
P_5.1

ale

### YoY Composition
P_5.2

ale

### SAAR Weighted Composition
P_5.3

ale

### YoY Weighted Composition
P_5.4

ale

### SAAR Historical averages
P_5.5

ale

### YoY Historical averages
P_5.6

ale