Objective

Objective of this analysis is to calculate the monthly and yearly changes (MoM, YoY) of road fuel prices in the UK.

Load packages

pacman::p_load(
  rio,          
  here,         
  tidyverse,
  lubridate,
  plotly,
  gganimate,
  ggExtra,      
  ggalt,      
  ggcorrplot,
  ggpubr,
  ggplot2, # ggarrange()
  zoo,
  data.table, 
  formattable,
  tidyr,
  kableExtra
  )    

Import data

mydata <- import(here("data", "Weekly_Fuel_Prices_240423.xlsx"), which = "All years", skip = 7)

Clean data

data <- mydata %>% janitor::clean_names()
data <- data %>% filter(date > "2004-06-1") # omit NA value 

str(data) # please note: date has POSIXct, format, not as.Date format 
## 'data.frame':    986 obs. of  11 variables:
##  $ date                              : POSIXct, format: "2004-06-07" "2004-06-14" ...
##  $ ulsp_pump_price_p_litre           : num  82.4 81.5 81 80.4 79.9 ...
##  $ ulsp_diff_on_previous_week_p_litre: num  0.0864 -0.8989 -0.4996 -0.634 -0.5348 ...
##  $ ulsp_diff_on_previous_year_p_litre: num  7.85 7.07 6.62 6.06 5.59 ...
##  $ duty_rate_ulsp_p_litre            : num  47.1 47.1 47.1 47.1 47.1 47.1 47.1 47.1 47.1 47.1 ...
##  $ vat_percent_rate_ulsp             : num  17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5 ...
##  $ ulsd_pump_price_p_litre           : num  83.7 82.6 82.1 81 80.5 ...
##  $ ulsd_diff_on_previous_week_p_litre: num  0 -1.047 -0.511 -1.049 -0.533 ...
##  $ ulsd_diff_on_previous_year_p_litre: num  6.88 5.92 5.47 4.54 4.05 ...
##  $ duty_rate_ulsd_p_litre            : num  47.1 47.1 47.1 47.1 47.1 47.1 47.1 47.1 47.1 47.1 ...
##  $ vat_percent_rate_ulsd             : num  17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5 17.5 ...

MoM, YoY changes

Calculation for ULSP only (1 variable)

## for 1 column only 
# data preparation
fuelprice <- data %>%
  mutate(YearMonth = format(date, "%Y-%m")) 

# Usual dplyr group_by() and summarize() by month.
monthly_price <- fuelprice %>%
  group_by(YearMonth) %>%
    summarize(MonthlyPrice = mean(ulsp_pump_price_p_litre)) %>%
      arrange(YearMonth)


# Calculating monthly and yearly changes
monthly_price <- monthly_price[monthly_price$YearMonth >= "2005-01", ] # Have a full year of 12 months. 

monthly_report <- monthly_price %>%
  mutate(
    mom = (MonthlyPrice - lag(MonthlyPrice)) / lag(MonthlyPrice),
    yoy = (MonthlyPrice - lag(MonthlyPrice, 12)) / lag(MonthlyPrice, 12)
  )

# Rounding value 
monthly_report <- monthly_report %>%
  mutate(
    mom = round(mom * 100, 1),
    yoy = round(yoy * 100, 1))

Calculation for ULSP & ULSD (multiple cols)

In order to calculate values for multiple cols, we use dplyr::mutate(across(), ~ func())

# data preparation 
fuelprice <- data %>%
  select(c(1:2,7)) %>% 
    mutate(YearMonth = format(date, "%Y-%m")) # create new column 

fuelprice <- fuelprice[, c(1,4,2,3)] # reorder column
str(fuelprice)
## 'data.frame':    986 obs. of  4 variables:
##  $ date                   : POSIXct, format: "2004-06-07" "2004-06-14" ...
##  $ YearMonth              : chr  "2004-06" "2004-06" "2004-06" "2004-06" ...
##  $ ulsp_pump_price_p_litre: num  82.4 81.5 81 80.4 79.9 ...
##  $ ulsd_pump_price_p_litre: num  83.7 82.6 82.1 81 80.5 ...
# Usual dplyr group_by() and summarize() by month.
monthly_price <- fuelprice %>%
  group_by(YearMonth) %>%
    summarise(across(c(ulsp_pump_price_p_litre, ulsd_pump_price_p_litre), ~ mean(.x, na.rm = TRUE), .names = "mean_{.col}")) %>%
      arrange(YearMonth)
# Calculating monthly changes
monthly_price <- monthly_price[monthly_price$YearMonth >= "2005-01", ] # Have a full year of 12 months. 

monthly_report <- 
  monthly_price %>%
       mutate(across(c("mean_ulsp_pump_price_p_litre", "mean_ulsd_pump_price_p_litre"),list(mom = ~(. - lag(., 1))/lag(., 1)))*100) %>%
          mutate(across(c("mean_ulsp_pump_price_p_litre", "mean_ulsd_pump_price_p_litre"), list(yoy = ~(. - lag(., 12))/lag(., 12)))*100)

monthly_report_2 <- 
  monthly_price %>%  # option 2
      mutate(across(c("mean_ulsp_pump_price_p_litre", "mean_ulsd_pump_price_p_litre"), ~(. - lag(., 1))/lag(., 1), .names = "mom_{.col}")) %>%
          mutate(across(c("mean_ulsp_pump_price_p_litre", "mean_ulsd_pump_price_p_litre"), ~(. - lag(., 12))/lag(., 12), .names = "yoy_{.col}"))
# Rounding value 
monthly_report <- 
  monthly_report %>%
     mutate(across(where(is.numeric), ~round(., 2)))

monthly_report_3 <- 
  monthly_report %>%  # opt 2
     mutate(across(ends_with("mom"), ~round(., 2))) %>% 
       mutate(across(ends_with("yoy"), ~round(., 2)))
# reorder cols 
monthly_report <- monthly_report[, c(1,2,4,6,3,5,7)] 

# rename cols 
col_names <- list("year_month", 
                  "ulsp_m_price", 
                  "ulsp_mom", 
                  "ulsp_yoy",
                  "ulsd_m_price", 
                  "ulsd_mom", 
                  "ulsd_yoy")

colnames(monthly_report) <- c(col_names)
# Display the table 
monthly_report_kable <- monthly_report

## Classic table
kbl(monthly_report_kable) %>%
  kable_classic() %>%
    add_header_above(c(" " = 1, "ULSP" = 3, "ULSD" = 3)) %>%  # Add header rows to group columns
      footnote(general = "Data is retrieved from GOV.UK on 30 Apr 2023. ",
          footnote_as_chunk = T, title_format = c("italic", "underline")) %>% 
            scroll_box(width = "100%", height = "200px")
ULSP
ULSD
year_month ulsp_m_price ulsp_mom ulsp_yoy ulsd_m_price ulsd_mom ulsd_yoy
2005-01 79.68 NA NA 84.40 NA NA
2005-02 80.12 0.55 NA 84.40 0.00 NA
2005-03 82.23 2.63 NA 86.62 2.63 NA
2005-04 85.16 3.57 NA 89.39 3.19 NA
2005-05 85.00 -0.19 NA 89.11 -0.31 NA
2005-06 85.31 0.37 NA 89.25 0.16 NA
2005-07 88.19 3.37 NA 92.15 3.24 NA
2005-08 90.33 2.43 NA 94.28 2.31 NA
2005-09 94.30 4.39 NA 97.17 3.06 NA
2005-10 93.63 -0.71 NA 96.81 -0.37 NA
2005-11 89.74 -4.16 NA 94.14 -2.76 NA
2005-12 87.50 -2.50 NA 91.81 -2.47 NA
2006-01 89.01 1.72 11.70 93.19 1.51 10.41
2006-02 89.62 0.69 11.86 93.77 0.62 11.10
2006-03 90.07 0.50 9.54 94.21 0.48 8.76
2006-04 93.53 3.85 9.83 97.05 3.01 8.57
2006-05 96.09 2.73 13.04 98.55 1.55 10.59
2006-06 95.29 -0.84 11.69 97.61 -0.95 9.36
2006-07 96.69 1.47 9.64 98.63 1.05 7.04
2006-08 96.50 -0.19 6.83 98.40 -0.23 4.38
2006-09 90.59 -6.13 -3.94 94.93 -3.53 -2.30
2006-10 86.16 -4.89 -7.98 91.57 -3.54 -5.41
2006-11 85.49 -0.78 -4.74 91.15 -0.46 -3.17
2006-12 87.13 1.92 -0.42 92.78 1.79 1.06
2007-01 86.91 -0.25 -2.36 91.64 -1.23 -1.66
2007-02 86.35 -0.64 -3.65 90.33 -1.44 -3.67
2007-03 88.62 2.63 -1.61 92.32 2.21 -2.01
2007-04 92.01 3.82 -1.63 94.84 2.73 -2.27
2007-05 95.34 3.63 -0.78 96.57 1.82 -2.01
2007-06 96.56 1.27 1.33 97.16 0.61 -0.46
2007-07 96.24 -0.33 -0.47 96.81 -0.36 -1.85
2007-08 95.61 -0.65 -0.92 96.60 -0.22 -1.84
2007-09 94.75 -0.90 4.60 96.51 -0.09 1.67
2007-10 97.36 2.75 13.00 99.48 3.07 8.64
2007-11 100.93 3.66 18.06 104.47 5.02 14.61
2007-12 102.61 1.67 17.77 107.47 2.87 15.83
2008-01 103.91 1.27 19.56 108.82 1.26 18.74
2008-02 104.01 0.10 20.45 109.26 0.41 20.96
2008-03 106.32 2.22 19.98 113.08 3.49 22.49
2008-04 108.23 1.79 17.63 117.28 3.72 23.66
2008-05 112.27 3.73 17.76 123.39 5.21 27.78
2008-06 117.57 4.72 21.76 130.53 5.78 34.35
2008-07 118.76 1.01 23.40 132.26 1.32 36.61
2008-08 113.31 -4.59 18.50 125.56 -5.07 29.98
2008-09 111.58 -1.52 17.76 123.30 -1.80 27.75
2008-10 104.44 -6.40 7.28 116.22 -5.74 16.83
2008-11 95.23 -8.82 -5.65 108.88 -6.32 4.22
2008-12 89.21 -6.32 -13.06 102.36 -5.99 -4.76
2009-01 86.26 -3.30 -16.98 98.43 -3.84 -9.54
2009-02 89.47 3.72 -13.98 100.45 2.05 -8.06
2009-03 90.42 1.06 -14.96 100.00 -0.45 -11.57
2009-04 94.40 4.40 -12.78 102.53 2.53 -12.58
2009-05 97.16 2.92 -13.46 103.20 0.66 -16.36
2009-06 101.61 4.59 -13.57 104.36 1.12 -20.05
2009-07 102.69 1.06 -13.53 103.76 -0.57 -21.54
2009-08 103.83 1.11 -8.37 104.41 0.62 -16.84
2009-09 106.17 2.26 -4.85 106.89 2.38 -13.30
2009-10 105.36 -0.77 0.87 106.40 -0.46 -8.45
2009-11 108.31 2.80 13.74 109.47 2.89 0.55
2009-12 108.01 -0.27 21.07 109.43 -0.04 6.92
2010-01 110.88 2.66 28.54 112.69 2.98 14.49
2010-02 111.83 0.85 24.99 113.49 0.71 12.98
2010-03 115.09 2.92 27.28 115.96 2.17 15.96
2010-04 120.19 4.43 27.33 121.31 4.62 18.32
2010-05 120.45 0.22 23.98 122.20 0.73 18.41
2010-06 117.94 -2.09 16.07 120.34 -1.52 15.32
2010-07 117.19 -0.63 14.13 119.62 -0.60 15.28
2010-08 115.96 -1.05 11.69 118.41 -1.02 13.40
2010-09 114.93 -0.89 8.25 117.52 -0.75 9.94
2010-10 116.95 1.76 11.01 120.13 2.22 12.91
2010-11 118.77 1.55 9.66 122.46 1.94 11.86
2010-12 121.99 2.72 12.95 126.15 3.01 15.27
2011-01 127.40 4.44 14.90 131.86 4.52 17.01
2011-02 129.00 1.25 15.36 134.07 1.68 18.13
2011-03 132.25 2.52 14.91 138.43 3.25 19.38
2011-04 134.29 1.54 11.73 140.81 1.72 16.07
2011-05 136.29 1.48 13.14 141.53 0.51 15.82
2011-06 135.59 -0.51 14.97 139.54 -1.41 15.95
2011-07 134.56 -0.76 14.82 138.85 -0.49 16.08
2011-08 135.47 0.68 16.82 139.90 0.76 18.15
2011-09 135.17 -0.22 17.61 139.59 -0.22 18.78
2011-10 134.68 -0.37 15.15 139.90 0.22 16.45
2011-11 133.66 -0.76 12.54 140.78 0.63 14.96
2011-12 132.55 -0.83 8.65 140.91 0.10 11.70
2012-01 133.24 0.52 4.58 141.61 0.49 7.39
2012-02 135.14 1.43 4.76 143.03 1.01 6.69
2012-03 138.41 2.42 4.66 145.64 1.82 5.21
2012-04 141.58 2.29 5.43 147.75 1.44 4.93
2012-05 137.14 -3.13 0.63 143.29 -3.02 1.24
2012-06 132.82 -3.15 -2.05 138.61 -3.26 -0.67
2012-07 131.61 -0.91 -2.19 137.03 -1.14 -1.31
2012-08 135.12 2.67 -0.26 140.30 2.39 0.29
2012-09 138.97 2.85 2.81 143.76 2.47 2.99
2012-10 138.06 -0.66 2.51 143.16 -0.42 2.33
2012-11 135.11 -2.13 1.09 141.74 -0.99 0.68
2012-12 132.29 -2.09 -0.20 140.28 -1.03 -0.45
2013-01 132.26 -0.03 -0.74 140.04 -0.17 -1.11
2013-02 136.32 3.08 0.87 143.66 2.59 0.44
2013-03 138.53 1.62 0.09 145.56 1.32 -0.06
2013-04 136.41 -1.53 -3.65 141.71 -2.65 -4.09
2013-05 133.34 -2.25 -2.78 138.51 -2.26 -3.33
2013-06 134.33 0.75 1.14 139.44 0.67 0.60
2013-07 135.01 0.51 2.59 139.85 0.29 2.05
2013-08 136.99 1.47 1.39 141.75 1.36 1.03
2013-09 136.51 -0.35 -1.77 141.91 0.11 -1.29
2013-10 131.56 -3.63 -4.71 138.96 -2.08 -2.93
2013-11 129.89 -1.27 -3.87 137.51 -1.05 -2.98
2013-12 130.41 0.40 -1.42 138.29 0.57 -1.42
2014-01 129.75 -0.51 -1.89 137.66 -0.46 -1.70
2014-02 129.01 -0.57 -5.37 136.86 -0.58 -4.73
2014-03 128.97 -0.03 -6.91 136.48 -0.28 -6.24
2014-04 128.95 -0.01 -5.47 136.03 -0.33 -4.01
2014-05 129.42 0.36 -2.93 136.26 0.17 -1.62
2014-06 130.01 0.45 -3.22 135.90 -0.27 -2.54
2014-07 131.02 0.78 -2.96 135.90 0.00 -2.83
2014-08 129.17 -1.41 -5.71 133.77 -1.57 -5.63
2014-09 128.40 -0.60 -5.94 133.11 -0.49 -6.20
2014-10 125.95 -1.91 -4.27 130.56 -1.92 -6.05
2014-11 122.92 -2.41 -5.36 127.66 -2.22 -7.16
2014-12 116.83 -4.96 -10.42 122.90 -3.73 -11.13
2015-01 108.27 -7.33 -16.56 115.56 -5.97 -16.05
2015-02 107.00 -1.17 -17.06 114.50 -0.92 -16.34
2015-03 110.80 3.55 -14.08 118.02 3.08 -13.52
2015-04 112.83 1.83 -12.50 119.24 1.03 -12.34
2015-05 115.28 2.17 -10.93 120.74 1.26 -11.39
2015-06 116.38 0.95 -10.48 121.23 0.41 -10.80
2015-07 116.49 0.09 -11.09 118.75 -2.05 -12.62
2015-08 114.12 -2.03 -11.65 112.48 -5.28 -15.91
2015-09 110.40 -3.27 -14.02 110.17 -2.05 -17.23
2015-10 108.74 -1.50 -13.67 110.78 0.55 -15.15
2015-11 107.19 -1.42 -12.79 110.16 -0.56 -13.70
2015-12 103.80 -3.17 -11.15 107.87 -2.08 -12.23
2016-01 101.78 -1.95 -5.99 103.52 -4.03 -10.42
2016-02 101.43 -0.35 -5.21 101.14 -2.30 -11.67
2016-03 102.29 0.85 -7.68 103.06 1.90 -12.68
2016-04 105.86 3.49 -6.18 106.48 3.32 -10.70
2016-05 108.69 2.67 -5.72 109.50 2.83 -9.31
2016-06 111.02 2.15 -4.60 112.07 2.35 -7.55
2016-07 111.79 0.69 -4.04 112.96 0.79 -4.87
2016-08 110.03 -1.57 -3.59 111.82 -1.01 -0.58
2016-09 111.23 1.10 0.76 113.28 1.31 2.82
2016-10 113.79 2.30 4.64 116.04 2.44 4.75
2016-11 115.37 1.39 7.63 117.98 1.67 7.10
2016-12 114.59 -0.68 10.39 117.98 -0.01 9.37
2017-01 118.61 3.51 16.54 121.87 3.30 17.73
2017-02 120.16 1.31 18.47 123.16 1.05 21.77
2017-03 119.20 -0.80 16.53 122.15 -0.82 18.52
2017-04 117.41 -1.50 10.91 120.26 -1.55 12.93
2017-05 116.44 -0.82 7.13 118.68 -1.31 8.39
2017-06 115.26 -1.01 3.82 117.29 -1.18 4.65
2017-07 113.87 -1.21 1.86 115.64 -1.40 2.38
2017-08 115.69 1.60 5.15 117.59 1.68 5.16
2017-09 118.20 2.17 6.27 120.05 2.10 5.98
2017-10 117.28 -0.78 3.07 120.52 0.39 3.85
2017-11 119.07 1.53 3.21 122.77 1.87 4.06
2017-12 119.91 0.71 4.65 123.54 0.62 4.71
2018-01 120.97 0.89 1.99 124.49 0.77 2.15
2018-02 120.84 -0.11 0.57 124.41 -0.06 1.02
2018-03 119.20 -1.36 0.00 122.90 -1.21 0.62
2018-04 120.72 1.28 2.82 124.46 1.27 3.50
2018-05 125.27 3.77 7.58 129.24 3.84 8.90
2018-06 128.03 2.21 11.08 132.05 2.17 12.59
2018-07 127.21 -0.65 11.71 131.61 -0.33 13.81
2018-08 128.60 1.09 11.16 132.78 0.89 12.92
2018-09 130.30 1.32 10.23 134.33 1.17 11.89
2018-10 130.51 0.17 11.28 136.19 1.38 13.00
2018-11 128.05 -1.88 7.54 136.48 0.22 11.17
2018-12 121.70 -4.96 1.49 131.86 -3.38 6.74
2019-01 119.55 -1.76 -1.17 129.45 -1.83 3.99
2019-02 119.09 -0.39 -1.45 129.30 -0.12 3.93
2019-03 120.28 1.00 0.91 130.71 1.09 6.35
2019-04 124.04 3.13 2.75 133.03 1.77 6.88
2019-05 128.28 3.42 2.40 135.76 2.05 5.04
2019-06 128.15 -0.10 0.09 134.34 -1.04 1.73
2019-07 127.26 -0.69 0.05 131.98 -1.76 0.28
2019-08 128.28 0.80 -0.25 132.58 0.45 -0.15
2019-09 127.25 -0.80 -2.33 131.78 -0.60 -1.90
2019-10 126.49 -0.60 -3.08 131.40 -0.29 -3.52
2019-11 125.51 -0.77 -1.98 130.31 -0.83 -4.52
2019-12 124.60 -0.73 2.39 129.90 -0.31 -1.49
2020-01 126.94 1.88 6.18 132.47 1.98 2.33
2020-02 124.45 -1.96 4.50 129.26 -2.42 -0.03
2020-03 119.42 -4.05 -0.72 123.85 -4.19 -5.25
2020-04 109.00 -8.72 -12.13 115.98 -6.35 -12.81
2020-05 106.24 -2.53 -17.18 113.42 -2.21 -16.45
2020-06 106.54 0.28 -16.86 112.67 -0.66 -16.13
2020-07 111.39 4.55 -12.47 116.73 3.60 -11.56
2020-08 113.10 1.53 -11.84 118.06 1.14 -10.95
2020-09 113.32 0.20 -10.95 118.17 0.10 -10.32
2020-10 113.19 -0.12 -10.51 118.08 -0.08 -10.14
2020-11 112.60 -0.53 -10.29 117.39 -0.59 -9.91
2020-12 114.08 1.32 -8.44 118.85 1.24 -8.51
2021-01 116.64 2.24 -8.12 121.20 1.98 -8.50
2021-02 120.15 3.01 -3.46 124.63 2.83 -3.59
2021-03 123.74 2.99 3.62 128.12 2.80 3.45
2021-04 125.48 1.40 15.12 129.50 1.08 11.65
2021-05 127.17 1.35 19.70 130.96 1.13 15.46
2021-06 129.75 2.02 21.78 133.38 1.85 18.38
2021-07 132.71 2.29 19.14 135.39 1.51 15.99
2021-08 134.59 1.41 19.00 137.05 1.22 16.08
2021-09 134.89 0.22 19.03 137.42 0.27 16.29
2021-10 138.64 2.78 22.48 142.24 3.51 20.46
2021-11 145.78 5.15 29.47 149.62 5.19 27.46
2021-12 145.80 0.01 27.80 149.55 -0.05 25.83
2022-01 145.05 -0.51 24.36 148.94 -0.41 22.89
2022-02 147.57 1.73 22.82 151.68 1.84 21.71
2022-03 160.23 8.58 29.49 170.49 12.40 33.07
2022-04 161.80 0.98 28.95 176.12 3.30 36.00
2022-05 165.84 2.50 30.41 179.71 2.04 37.22
2022-06 183.82 10.85 41.68 192.29 7.00 44.17
2022-07 189.42 3.05 42.73 197.84 2.89 46.13
2022-08 175.17 -7.52 30.15 186.56 -5.70 36.13
2022-09 166.50 -4.95 23.44 181.66 -2.63 32.19
2022-10 163.61 -1.74 18.01 183.94 1.26 29.32
2022-11 163.61 0.00 12.23 187.95 2.18 25.61
2022-12 155.29 -5.08 6.51 179.15 -4.68 19.79
2023-01 149.21 -3.92 2.86 172.08 -3.95 15.54
2023-02 147.93 -0.86 0.25 169.47 -1.51 11.73
2023-03 146.73 -0.81 -8.43 166.45 -1.78 -2.37
2023-04 145.83 -0.62 -9.87 162.47 -2.39 -7.75
Note: Data is retrieved from GOV.UK on 30 Apr 2023.
## highlight in text
monthly_report_kable$ulsp_mom <- cell_spec(monthly_report_kable$ulsp_mom, 
                                      color = ifelse(is.na(monthly_report_kable$ulsp_mom), "lightgrey",
                                          ifelse(monthly_report_kable$ulsp_mom < 0, "red", "blue"))
                                      )

## display table 
kbl(monthly_report_kable, escape = F) %>%
  kable_paper("striped", full_width = F) %>% 
    scroll_box(width = "100%", height = "200px")
year_month ulsp_m_price ulsp_mom ulsp_yoy ulsd_m_price ulsd_mom ulsd_yoy
2005-01 79.68 NA NA 84.40 NA NA
2005-02 80.12 0.55 NA 84.40 0.00 NA
2005-03 82.23 2.63 NA 86.62 2.63 NA
2005-04 85.16 3.57 NA 89.39 3.19 NA
2005-05 85.00 -0.19 NA 89.11 -0.31 NA
2005-06 85.31 0.37 NA 89.25 0.16 NA
2005-07 88.19 3.37 NA 92.15 3.24 NA
2005-08 90.33 2.43 NA 94.28 2.31 NA
2005-09 94.30 4.39 NA 97.17 3.06 NA
2005-10 93.63 -0.71 NA 96.81 -0.37 NA
2005-11 89.74 -4.16 NA 94.14 -2.76 NA
2005-12 87.50 -2.5 NA 91.81 -2.47 NA
2006-01 89.01 1.72 11.70 93.19 1.51 10.41
2006-02 89.62 0.69 11.86 93.77 0.62 11.10
2006-03 90.07 0.5 9.54 94.21 0.48 8.76
2006-04 93.53 3.85 9.83 97.05 3.01 8.57
2006-05 96.09 2.73 13.04 98.55 1.55 10.59
2006-06 95.29 -0.84 11.69 97.61 -0.95 9.36
2006-07 96.69 1.47 9.64 98.63 1.05 7.04
2006-08 96.50 -0.19 6.83 98.40 -0.23 4.38
2006-09 90.59 -6.13 -3.94 94.93 -3.53 -2.30
2006-10 86.16 -4.89 -7.98 91.57 -3.54 -5.41
2006-11 85.49 -0.78 -4.74 91.15 -0.46 -3.17
2006-12 87.13 1.92 -0.42 92.78 1.79 1.06
2007-01 86.91 -0.25 -2.36 91.64 -1.23 -1.66
2007-02 86.35 -0.64 -3.65 90.33 -1.44 -3.67
2007-03 88.62 2.63 -1.61 92.32 2.21 -2.01
2007-04 92.01 3.82 -1.63 94.84 2.73 -2.27
2007-05 95.34 3.63 -0.78 96.57 1.82 -2.01
2007-06 96.56 1.27 1.33 97.16 0.61 -0.46
2007-07 96.24 -0.33 -0.47 96.81 -0.36 -1.85
2007-08 95.61 -0.65 -0.92 96.60 -0.22 -1.84
2007-09 94.75 -0.9 4.60 96.51 -0.09 1.67
2007-10 97.36 2.75 13.00 99.48 3.07 8.64
2007-11 100.93 3.66 18.06 104.47 5.02 14.61
2007-12 102.61 1.67 17.77 107.47 2.87 15.83
2008-01 103.91 1.27 19.56 108.82 1.26 18.74
2008-02 104.01 0.1 20.45 109.26 0.41 20.96
2008-03 106.32 2.22 19.98 113.08 3.49 22.49
2008-04 108.23 1.79 17.63 117.28 3.72 23.66
2008-05 112.27 3.73 17.76 123.39 5.21 27.78
2008-06 117.57 4.72 21.76 130.53 5.78 34.35
2008-07 118.76 1.01 23.40 132.26 1.32 36.61
2008-08 113.31 -4.59 18.50 125.56 -5.07 29.98
2008-09 111.58 -1.52 17.76 123.30 -1.80 27.75
2008-10 104.44 -6.4 7.28 116.22 -5.74 16.83
2008-11 95.23 -8.82 -5.65 108.88 -6.32 4.22
2008-12 89.21 -6.32 -13.06 102.36 -5.99 -4.76
2009-01 86.26 -3.3 -16.98 98.43 -3.84 -9.54
2009-02 89.47 3.72 -13.98 100.45 2.05 -8.06
2009-03 90.42 1.06 -14.96 100.00 -0.45 -11.57
2009-04 94.40 4.4 -12.78 102.53 2.53 -12.58
2009-05 97.16 2.92 -13.46 103.20 0.66 -16.36
2009-06 101.61 4.59 -13.57 104.36 1.12 -20.05
2009-07 102.69 1.06 -13.53 103.76 -0.57 -21.54
2009-08 103.83 1.11 -8.37 104.41 0.62 -16.84
2009-09 106.17 2.26 -4.85 106.89 2.38 -13.30
2009-10 105.36 -0.77 0.87 106.40 -0.46 -8.45
2009-11 108.31 2.8 13.74 109.47 2.89 0.55
2009-12 108.01 -0.27 21.07 109.43 -0.04 6.92
2010-01 110.88 2.66 28.54 112.69 2.98 14.49
2010-02 111.83 0.85 24.99 113.49 0.71 12.98
2010-03 115.09 2.92 27.28 115.96 2.17 15.96
2010-04 120.19 4.43 27.33 121.31 4.62 18.32
2010-05 120.45 0.22 23.98 122.20 0.73 18.41
2010-06 117.94 -2.09 16.07 120.34 -1.52 15.32
2010-07 117.19 -0.63 14.13 119.62 -0.60 15.28
2010-08 115.96 -1.05 11.69 118.41 -1.02 13.40
2010-09 114.93 -0.89 8.25 117.52 -0.75 9.94
2010-10 116.95 1.76 11.01 120.13 2.22 12.91
2010-11 118.77 1.55 9.66 122.46 1.94 11.86
2010-12 121.99 2.72 12.95 126.15 3.01 15.27
2011-01 127.40 4.44 14.90 131.86 4.52 17.01
2011-02 129.00 1.25 15.36 134.07 1.68 18.13
2011-03 132.25 2.52 14.91 138.43 3.25 19.38
2011-04 134.29 1.54 11.73 140.81 1.72 16.07
2011-05 136.29 1.48 13.14 141.53 0.51 15.82
2011-06 135.59 -0.51 14.97 139.54 -1.41 15.95
2011-07 134.56 -0.76 14.82 138.85 -0.49 16.08
2011-08 135.47 0.68 16.82 139.90 0.76 18.15
2011-09 135.17 -0.22 17.61 139.59 -0.22 18.78
2011-10 134.68 -0.37 15.15 139.90 0.22 16.45
2011-11 133.66 -0.76 12.54 140.78 0.63 14.96
2011-12 132.55 -0.83 8.65 140.91 0.10 11.70
2012-01 133.24 0.52 4.58 141.61 0.49 7.39
2012-02 135.14 1.43 4.76 143.03 1.01 6.69
2012-03 138.41 2.42 4.66 145.64 1.82 5.21
2012-04 141.58 2.29 5.43 147.75 1.44 4.93
2012-05 137.14 -3.13 0.63 143.29 -3.02 1.24
2012-06 132.82 -3.15 -2.05 138.61 -3.26 -0.67
2012-07 131.61 -0.91 -2.19 137.03 -1.14 -1.31
2012-08 135.12 2.67 -0.26 140.30 2.39 0.29
2012-09 138.97 2.85 2.81 143.76 2.47 2.99
2012-10 138.06 -0.66 2.51 143.16 -0.42 2.33
2012-11 135.11 -2.13 1.09 141.74 -0.99 0.68
2012-12 132.29 -2.09 -0.20 140.28 -1.03 -0.45
2013-01 132.26 -0.03 -0.74 140.04 -0.17 -1.11
2013-02 136.32 3.08 0.87 143.66 2.59 0.44
2013-03 138.53 1.62 0.09 145.56 1.32 -0.06
2013-04 136.41 -1.53 -3.65 141.71 -2.65 -4.09
2013-05 133.34 -2.25 -2.78 138.51 -2.26 -3.33
2013-06 134.33 0.75 1.14 139.44 0.67 0.60
2013-07 135.01 0.51 2.59 139.85 0.29 2.05
2013-08 136.99 1.47 1.39 141.75 1.36 1.03
2013-09 136.51 -0.35 -1.77 141.91 0.11 -1.29
2013-10 131.56 -3.63 -4.71 138.96 -2.08 -2.93
2013-11 129.89 -1.27 -3.87 137.51 -1.05 -2.98
2013-12 130.41 0.4 -1.42 138.29 0.57 -1.42
2014-01 129.75 -0.51 -1.89 137.66 -0.46 -1.70
2014-02 129.01 -0.57 -5.37 136.86 -0.58 -4.73
2014-03 128.97 -0.03 -6.91 136.48 -0.28 -6.24
2014-04 128.95 -0.01 -5.47 136.03 -0.33 -4.01
2014-05 129.42 0.36 -2.93 136.26 0.17 -1.62
2014-06 130.01 0.45 -3.22 135.90 -0.27 -2.54
2014-07 131.02 0.78 -2.96 135.90 0.00 -2.83
2014-08 129.17 -1.41 -5.71 133.77 -1.57 -5.63
2014-09 128.40 -0.6 -5.94 133.11 -0.49 -6.20
2014-10 125.95 -1.91 -4.27 130.56 -1.92 -6.05
2014-11 122.92 -2.41 -5.36 127.66 -2.22 -7.16
2014-12 116.83 -4.96 -10.42 122.90 -3.73 -11.13
2015-01 108.27 -7.33 -16.56 115.56 -5.97 -16.05
2015-02 107.00 -1.17 -17.06 114.50 -0.92 -16.34
2015-03 110.80 3.55 -14.08 118.02 3.08 -13.52
2015-04 112.83 1.83 -12.50 119.24 1.03 -12.34
2015-05 115.28 2.17 -10.93 120.74 1.26 -11.39
2015-06 116.38 0.95 -10.48 121.23 0.41 -10.80
2015-07 116.49 0.09 -11.09 118.75 -2.05 -12.62
2015-08 114.12 -2.03 -11.65 112.48 -5.28 -15.91
2015-09 110.40 -3.27 -14.02 110.17 -2.05 -17.23
2015-10 108.74 -1.5 -13.67 110.78 0.55 -15.15
2015-11 107.19 -1.42 -12.79 110.16 -0.56 -13.70
2015-12 103.80 -3.17 -11.15 107.87 -2.08 -12.23
2016-01 101.78 -1.95 -5.99 103.52 -4.03 -10.42
2016-02 101.43 -0.35 -5.21 101.14 -2.30 -11.67
2016-03 102.29 0.85 -7.68 103.06 1.90 -12.68
2016-04 105.86 3.49 -6.18 106.48 3.32 -10.70
2016-05 108.69 2.67 -5.72 109.50 2.83 -9.31
2016-06 111.02 2.15 -4.60 112.07 2.35 -7.55
2016-07 111.79 0.69 -4.04 112.96 0.79 -4.87
2016-08 110.03 -1.57 -3.59 111.82 -1.01 -0.58
2016-09 111.23 1.1 0.76 113.28 1.31 2.82
2016-10 113.79 2.3 4.64 116.04 2.44 4.75
2016-11 115.37 1.39 7.63 117.98 1.67 7.10
2016-12 114.59 -0.68 10.39 117.98 -0.01 9.37
2017-01 118.61 3.51 16.54 121.87 3.30 17.73
2017-02 120.16 1.31 18.47 123.16 1.05 21.77
2017-03 119.20 -0.8 16.53 122.15 -0.82 18.52
2017-04 117.41 -1.5 10.91 120.26 -1.55 12.93
2017-05 116.44 -0.82 7.13 118.68 -1.31 8.39
2017-06 115.26 -1.01 3.82 117.29 -1.18 4.65
2017-07 113.87 -1.21 1.86 115.64 -1.40 2.38
2017-08 115.69 1.6 5.15 117.59 1.68 5.16
2017-09 118.20 2.17 6.27 120.05 2.10 5.98
2017-10 117.28 -0.78 3.07 120.52 0.39 3.85
2017-11 119.07 1.53 3.21 122.77 1.87 4.06
2017-12 119.91 0.71 4.65 123.54 0.62 4.71
2018-01 120.97 0.89 1.99 124.49 0.77 2.15
2018-02 120.84 -0.11 0.57 124.41 -0.06 1.02
2018-03 119.20 -1.36 0.00 122.90 -1.21 0.62
2018-04 120.72 1.28 2.82 124.46 1.27 3.50
2018-05 125.27 3.77 7.58 129.24 3.84 8.90
2018-06 128.03 2.21 11.08 132.05 2.17 12.59
2018-07 127.21 -0.65 11.71 131.61 -0.33 13.81
2018-08 128.60 1.09 11.16 132.78 0.89 12.92
2018-09 130.30 1.32 10.23 134.33 1.17 11.89
2018-10 130.51 0.17 11.28 136.19 1.38 13.00
2018-11 128.05 -1.88 7.54 136.48 0.22 11.17
2018-12 121.70 -4.96 1.49 131.86 -3.38 6.74
2019-01 119.55 -1.76 -1.17 129.45 -1.83 3.99
2019-02 119.09 -0.39 -1.45 129.30 -0.12 3.93
2019-03 120.28 1 0.91 130.71 1.09 6.35
2019-04 124.04 3.13 2.75 133.03 1.77 6.88
2019-05 128.28 3.42 2.40 135.76 2.05 5.04
2019-06 128.15 -0.1 0.09 134.34 -1.04 1.73
2019-07 127.26 -0.69 0.05 131.98 -1.76 0.28
2019-08 128.28 0.8 -0.25 132.58 0.45 -0.15
2019-09 127.25 -0.8 -2.33 131.78 -0.60 -1.90
2019-10 126.49 -0.6 -3.08 131.40 -0.29 -3.52
2019-11 125.51 -0.77 -1.98 130.31 -0.83 -4.52
2019-12 124.60 -0.73 2.39 129.90 -0.31 -1.49
2020-01 126.94 1.88 6.18 132.47 1.98 2.33
2020-02 124.45 -1.96 4.50 129.26 -2.42 -0.03
2020-03 119.42 -4.05 -0.72 123.85 -4.19 -5.25
2020-04 109.00 -8.72 -12.13 115.98 -6.35 -12.81
2020-05 106.24 -2.53 -17.18 113.42 -2.21 -16.45
2020-06 106.54 0.28 -16.86 112.67 -0.66 -16.13
2020-07 111.39 4.55 -12.47 116.73 3.60 -11.56
2020-08 113.10 1.53 -11.84 118.06 1.14 -10.95
2020-09 113.32 0.2 -10.95 118.17 0.10 -10.32
2020-10 113.19 -0.12 -10.51 118.08 -0.08 -10.14
2020-11 112.60 -0.53 -10.29 117.39 -0.59 -9.91
2020-12 114.08 1.32 -8.44 118.85 1.24 -8.51
2021-01 116.64 2.24 -8.12 121.20 1.98 -8.50
2021-02 120.15 3.01 -3.46 124.63 2.83 -3.59
2021-03 123.74 2.99 3.62 128.12 2.80 3.45
2021-04 125.48 1.4 15.12 129.50 1.08 11.65
2021-05 127.17 1.35 19.70 130.96 1.13 15.46
2021-06 129.75 2.02 21.78 133.38 1.85 18.38
2021-07 132.71 2.29 19.14 135.39 1.51 15.99
2021-08 134.59 1.41 19.00 137.05 1.22 16.08
2021-09 134.89 0.22 19.03 137.42 0.27 16.29
2021-10 138.64 2.78 22.48 142.24 3.51 20.46
2021-11 145.78 5.15 29.47 149.62 5.19 27.46
2021-12 145.80 0.01 27.80 149.55 -0.05 25.83
2022-01 145.05 -0.51 24.36 148.94 -0.41 22.89
2022-02 147.57 1.73 22.82 151.68 1.84 21.71
2022-03 160.23 8.58 29.49 170.49 12.40 33.07
2022-04 161.80 0.98 28.95 176.12 3.30 36.00
2022-05 165.84 2.5 30.41 179.71 2.04 37.22
2022-06 183.82 10.85 41.68 192.29 7.00 44.17
2022-07 189.42 3.05 42.73 197.84 2.89 46.13
2022-08 175.17 -7.52 30.15 186.56 -5.70 36.13
2022-09 166.50 -4.95 23.44 181.66 -2.63 32.19
2022-10 163.61 -1.74 18.01 183.94 1.26 29.32
2022-11 163.61 0 12.23 187.95 2.18 25.61
2022-12 155.29 -5.08 6.51 179.15 -4.68 19.79
2023-01 149.21 -3.92 2.86 172.08 -3.95 15.54
2023-02 147.93 -0.86 0.25 169.47 -1.51 11.73
2023-03 146.73 -0.81 -8.43 166.45 -1.78 -2.37
2023-04 145.83 -0.62 -9.87 162.47 -2.39 -7.75
# format
formattable(
  head(monthly_report, 15),
  align = c("l", rep("r", NCOL(monthly_report) - 1)), # format column to left / right aligment 
           list(`year_month` = formatter("span", style = ~ style(color = "grey",font.weight = "bold")))
            )
year_month ulsp_m_price ulsp_mom ulsp_yoy ulsd_m_price ulsd_mom ulsd_yoy
2005-01 79.68 NA NA 84.40 NA NA
2005-02 80.12 0.55 NA 84.40 0.00 NA
2005-03 82.23 2.63 NA 86.62 2.63 NA
2005-04 85.16 3.57 NA 89.39 3.19 NA
2005-05 85.00 -0.19 NA 89.11 -0.31 NA
2005-06 85.31 0.37 NA 89.25 0.16 NA
2005-07 88.19 3.37 NA 92.15 3.24 NA
2005-08 90.33 2.43 NA 94.28 2.31 NA
2005-09 94.30 4.39 NA 97.17 3.06 NA
2005-10 93.63 -0.71 NA 96.81 -0.37 NA
2005-11 89.74 -4.16 NA 94.14 -2.76 NA
2005-12 87.50 -2.50 NA 91.81 -2.47 NA
2006-01 89.01 1.72 11.70 93.19 1.51 10.41
2006-02 89.62 0.69 11.86 93.77 0.62 11.10
2006-03 90.07 0.50 9.54 94.21 0.48 8.76
# diff_formatter <- formatter("span", style = x ~ style(font.weight = "bold", color = ifelse(x > 0, "#71CA97", ifelse(x < 0, "red", "black")),"font.size" = "12px"), x ~ icontext(ifelse(x>0, "arrow-up", ifelse(x<0, "arrow-down", "")), x))

diff_formatter <- 
  formatter("span", style = x ~ style(color = ifelse(x > 0, "#71CA97", ifelse(x < 0, "red", "black")),"font.size" = "12px"),
            x ~ icontext(ifelse(x>0, "arrow-up", ifelse(x<0, "arrow-down", "")), x))

formattable(
  head(monthly_report, 15), # if not using head, the table will be long
  align = c("l", rep("r", NCOL(monthly_report) - 1)), 
  list(
  `year_month` = formatter("span", style = ~ style(color = "grey",font.weight = "bold")),
  `ulsp_m_price` = color_tile("#DeF7E9", "#71CA97"),
  `ulsd_m_price` = color_tile("#DeF7E9", "#71CA97"),
  `ulsp_mom` = diff_formatter,
  `ulsd_mom` = diff_formatter,
  `ulsp_yoy` = diff_formatter,
  `ulsd_yoy` = diff_formatter)
  )
year_month ulsp_m_price ulsp_mom ulsp_yoy ulsd_m_price ulsd_mom ulsd_yoy
2005-01 79.68 NA NA 84.40 NA NA
2005-02 80.12 0.55 NA 84.40 0 NA
2005-03 82.23 2.63 NA 86.62 2.63 NA
2005-04 85.16 3.57 NA 89.39 3.19 NA
2005-05 85.00 -0.19 NA 89.11 -0.31 NA
2005-06 85.31 0.37 NA 89.25 0.16 NA
2005-07 88.19 3.37 NA 92.15 3.24 NA
2005-08 90.33 2.43 NA 94.28 2.31 NA
2005-09 94.30 4.39 NA 97.17 3.06 NA
2005-10 93.63 -0.71 NA 96.81 -0.37 NA
2005-11 89.74 -4.16 NA 94.14 -2.76 NA
2005-12 87.50 -2.5 NA 91.81 -2.47 NA
2006-01 89.01 1.72 11.7 93.19 1.51 10.41
2006-02 89.62 0.69 11.86 93.77 0.62 11.1
2006-03 90.07 0.5 9.54 94.21 0.48 8.76

Reference

  1. National statistics - Weekly road fuel prices