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
## NDQ07
RSM05 <- cso_get_data("RSM05")
RSM05 <- RSM05 %>%
pivot_longer(!1:2, names_to = "year_month")
# Date transformation
## Take adjusted index only
RSM05 <- RSM05%>%filter(Statistic=="Retail Sales Index Value Adjusted"|Statistic=="Retail Sales Index Volume Adjusted")
RSM05$Month <- as.Date(paste(RSM05$year_month, "01", sep = "-"), "%YM%m-%d")
RSM05$Year <- year(RSM05$Month)
RSM05$Lag <- Lag(RSM05$value,1)
RSM05$Diff <- RSM05$value-RSM05$Lag
RSM05_A <- RSM05%>%
filter(NACE.Group=="All retail businesses")
RSM05_B <- RSM05%>%
filter(NACE.Group=="Motor trades (45)"|NACE.Group=="Retail sale in non-specialised stores with food, beverages or tobacco predominating (4711)"|NACE.Group=="Department stores (4719)"|NACE.Group=="Retail sale of automotive fuel (4730)"|NACE.Group=="Retail sale of hardware, paints and glass (4752)"|NACE.Group=="Retail sale of furniture and lighting (4759)"|NACE.Group=="Bars (5630)")
RSM05_A1 <- RSM05_A%>%filter(Statistic=="Retail Sales Index Value Adjusted")
RSM05_A2 <- RSM05_A%>%filter(Statistic=="Retail Sales Index Volume Adjusted")
RSM05_B1 <- RSM05_B%>%filter(Statistic=="Retail Sales Index Value Adjusted")
RSM05_B2 <- RSM05_B%>%filter(Statistic=="Retail Sales Index Volume Adjusted")
RSM05_A1_tail_1 <- tail(RSM05_A1,1)
RSM05_A1_tail_1_lag <-head(tail(RSM05_A1,2),1)
RSM05_A2_tail_1 <- tail(RSM05_A2,1)
RSM05_A2_tail_1_lag <-head(tail(RSM05_A2,2),1)
Retail Sales Index Value Adjusted for 2022M06 is 122.9. This represents a change of -0.3 from 2022M05 which was 123.2. Retail Sales Index Volume Adjusted is at 124.4. This represents a change of -1.6 from 2022M05 which was 126.
Fig1<-ggplot(data=subset(RSM05_A,Year >= "2021"), aes(x=Month, y=value, group=Statistic, colour=Statistic))+
geom_line(aes(group=Statistic),size = 1.05, linetype=1, alpha = 0.65)+
scale_colour_manual(values=c("#4aa98a","#a55a94"))+
labs(title = "RSI Value (Adjusted) - CSO: RSM05", subtitle = "Post 2021")+
xlab("Year-Month")+
ylab("2015 = 100")+
scale_x_date(date_labels="%b-%Y",date_breaks ="3 month")+
theme(axis.text.x = element_text(angle=0))+
theme(legend.position="bottom")+
theme(axis.text = element_text(size = rel(1)))+
theme(plot.title=(element_text(vjust =2)))+
theme(panel.border = element_rect(linetype = 1, fill = NA))
Fig1
LineA1<-ggplot(data=RSM05_A1,aes(x=Month,y=value))+
geom_line(size = 1.15, linetype=1, alpha = 0.6, colour = "#4aa98a")+
geom_hline(aes(yintercept=100),
colour= "#404040",
linetype = 1)+
labs(title = "RSI Value (Adjusted) - CSO: RSM05", subtitle = "2015 to Date")+
xlab("Year-Month")+
ylab("Retail Sales Index (Base Dec 2015=100)")+
theme(panel.border = element_rect(linetype = 1, fill = NA))
LineA1
TableA1%>%
kbl(caption = "Retail Sales Index Value Adjusted")%>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width =T)%>%
row_spec(6, bold = T)%>%
kable_styling(position = "center")%>%
pack_rows("Latest Period", 6, 6, color="#4aa98a")%>%
scroll_box(width = "600px", height = "300px")
NACE.Group | year_month | value | Diff |
---|---|---|---|
All retail businesses | 2022M01 | 117.4 | -3.0 |
All retail businesses | 2022M02 | 121.1 | 3.7 |
All retail businesses | 2022M03 | 121.0 | -0.1 |
All retail businesses | 2022M04 | 130.5 | 9.5 |
All retail businesses | 2022M05 | 123.2 | -7.3 |
Latest Period | |||
All retail businesses | 2022M06 | 122.9 | -0.3 |
LineA2<-ggplot(data=RSM05_A2,aes(x=Month,y=value))+
geom_line(size = 1.15, linetype=1, alpha = 0.6, colour = "#a55a94")+
geom_hline(aes(yintercept=100),
colour= "#404040",
linetype = 1)+
labs(title = "RSI Volume (Adjusted) - CSO: RSM05", subtitle = "2015 to Date")+
xlab("Year-Month")+
ylab("Retail Sales Index (Base Dec 2015=100)")+
theme(panel.border = element_rect(linetype = 1, fill = NA))
LineA2
TableA2%>%
kbl(caption = "Retail Sales Index Volume Adjusted")%>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width =T)%>%
row_spec(6, bold = T)%>%
kable_styling(position = "center")%>%
pack_rows("Latest Period", 6, 6, color="#4aa98a")%>%
scroll_box(width = "600px", height = "300px")
NACE.Group | year_month | value | Diff |
---|---|---|---|
All retail businesses | 2022M01 | 123.2 | -1.7 |
All retail businesses | 2022M02 | 123.7 | 0.5 |
All retail businesses | 2022M03 | 123.2 | -0.5 |
All retail businesses | 2022M04 | 127.7 | 4.5 |
All retail businesses | 2022M05 | 126.0 | -1.7 |
Latest Period | |||
All retail businesses | 2022M06 | 124.4 | -1.6 |
NACE Rev. 2 are statistical classifications of economic activities in the European Union.
Black line represents 2015 = 100
FigNACE<-ggplot(RSM05_B1, aes(x=Month, y=value, group=NACE.Group, colour=NACE.Group))+
geom_line(aes(group=NACE.Group),size = 1.05, linetype=1, alpha = 0.65)+
labs(title = "RSI Value by NACE Group (Adjusted) - CSO: RSM05")+
xlab("Year-Month")+
ylab("2015 = 100")+
geom_hline(aes(yintercept=100),
colour= "#404040",
linetype = 1)+
scale_x_date(date_labels="%b-%Y",date_breaks ="3 month")+
theme(axis.text.x = element_text(angle=90))+
theme(axis.text.x=element_text(size=10))+
theme(legend.position="bottom")+
theme(axis.text = element_text(size = rel(1)))+
theme(plot.title=(element_text(vjust =2)))+
theme(panel.border = element_rect(linetype = 1, fill = NA))
FigNACE + facet_wrap(~NACE.Group, ncol = 1)
#https://www3.nd.edu/~steve/computing_with_data/13_Facets/facets.html
FigNACE2<-ggplot(RSM05_B1, aes(x=Month, y=value, group=NACE.Group, colour=NACE.Group))+
geom_line(aes(group=NACE.Group),size = 1.05, linetype=1, alpha = 0.65)+
labs(title = "RSI Volume by NACE Group (Adjusted) - CSO: RSM05")+
xlab("Year-Month")+
ylab("2015 = 100")+
geom_hline(aes(yintercept=100),
colour= "#404040",
linetype = 1)+
scale_x_date(date_labels="%b-%Y",date_breaks ="3 month")+
theme(axis.text.x = element_text(angle=90))+
theme(axis.text.x=element_text(size=10))+
theme(legend.position="bottom")+
theme(axis.text = element_text(size = rel(1)))+
theme(plot.title=(element_text(vjust =2)))+
theme(panel.border = element_rect(linetype = 1, fill = NA))
FigNACE2 + facet_wrap(~NACE.Group, ncol = 1)