# libraries
library(readxl)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(scales)
library(viridis)
## Loading required package: viridisLite
## 
## Attaching package: 'viridis'
## The following object is masked from 'package:scales':
## 
##     viridis_pal
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union

Data Preprocessing

# data loading
householdData <- read_excel("5682001.xlsx",sheet = "Data1",skip = 10,col_names = FALSE)
## New names:
## • `` -> `...1`
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## • `` -> `...18`
## • `` -> `...19`
## • `` -> `...20`
## • `` -> `...21`
## • `` -> `...22`
## • `` -> `...23`
## • `` -> `...24`
## • `` -> `...25`
## • `` -> `...26`
## • `` -> `...27`
## • `` -> `...28`
## • `` -> `...29`
## • `` -> `...30`
## • `` -> `...31`
## • `` -> `...32`
## • `` -> `...33`
## • `` -> `...34`
## • `` -> `...35`
## • `` -> `...36`
## • `` -> `...37`
## • `` -> `...38`
## • `` -> `...39`
## • `` -> `...40`
## • `` -> `...41`
## • `` -> `...42`
## • `` -> `...43`
## • `` -> `...44`
## • `` -> `...45`
## • `` -> `...46`
# get the first 14 data
householdData <- householdData[,1:14]
names(householdData) <- c("Month","Total","Goods","Services","Discretionary","NonDiscretionary","Total_Monthly",
               "Goods_Monthly","Services_Monthly","Discretionary_Monthly","NonDiscretionary_Monthly","Total_Annual",
               "Goods_Annual","Services_Annual")
# convert to numeric
householdData <- householdData %>% mutate(across(-Month, as.numeric))
# set date type
householdData$Month <- as.Date(householdData$Month)
# summary for the total variable in data
summary(householdData$Total)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   39762   48794   54055   57629   68041   86199
# find the total class
class(householdData$Total)
## [1] "numeric"
# check the "na" in month data
sum(is.na(householdData$Month))
## [1] 0
# display first 20 data
head(householdData$Month, 20)
##  [1] "2012-07-01" "2012-08-01" "2012-09-01" "2012-10-01" "2012-11-01"
##  [6] "2012-12-01" "2013-01-01" "2013-02-01" "2013-03-01" "2013-04-01"
## [11] "2013-05-01" "2013-06-01" "2013-07-01" "2013-08-01" "2013-09-01"
## [16] "2013-10-01" "2013-11-01" "2013-12-01" "2014-01-01" "2014-02-01"
# display last 20 data
tail(householdData$Month, 20)
##  [1] "2024-09-01" "2024-10-01" "2024-11-01" "2024-12-01" "2025-01-01"
##  [6] "2025-02-01" "2025-03-01" "2025-04-01" "2025-05-01" "2025-06-01"
## [11] "2025-07-01" "2025-08-01" "2025-09-01" "2025-10-01" "2025-11-01"
## [16] "2025-12-01" "2026-01-01" "2026-02-01" "2026-03-01" "2026-04-01"

CHART 1:

Australian Household Spending Since 2012

# chart one - Line chart
chartONE <- ggplot(householdData, aes(Month, Total)) +geom_line(colour = "#D55E00",linewidth = 1.2) +
  labs(title = "Australian Household Spending Since 2012",subtitle = "Monthly Household Spending Indicator",
       x = "",y = "Spending ($ Million)") +scale_y_continuous(labels = comma) + theme_minimal()
ggplotly(chartONE)

CHART 2:

Services Spending Has Grown Faster Than Goods Spending

# goods data for chart two
goods_services <- householdData %>% select(Month,Goods,Services) %>% pivot_longer(-Month,names_to = "Type",values_to = "Spending")
# line chart for comparision
chartTwo <- ggplot(goods_services,aes(Month,Spending,colour = Type)) +
  geom_line(linewidth = 1.2) + labs(
    title = "Services Spending Has Grown Faster Than Goods Spending",
    subtitle = "Australian household expenditure by spending type",
    x = "", y = "Spending ($ Million)") + scale_y_continuous(labels = comma) +
  theme_minimal()
ggplotly(chartTwo)

CHART 3:

Essential Spending Continues To Dominate Household Budgets

# budget data for chart three
essential <- householdData %>% select(Month,Discretionary,NonDiscretionary) %>%
  pivot_longer(-Month,names_to = "Category",values_to = "Spending")
# chart three
chartTHREE <- ggplot(essential,aes(Month,Spending,fill = Category)) +
  geom_area(alpha = 0.8) +
  labs(title = "Essential Spending Continues To Dominate Household Budgets",
       subtitle = "Discretionary versus non-discretionary spending",x = "",y = "Spending ($ Million)") +
  scale_y_continuous(labels = comma) +
  theme_minimal()
ggplotly(chartTHREE)

CHART 4:

Monthly Spending Growth Is Uneven Across Categories

# growth data for chart 4
growth <- householdData %>% select(Month,Total_Monthly,Goods_Monthly,Services_Monthly,Discretionary_Monthly,NonDiscretionary_Monthly) %>%
  pivot_longer(-Month,names_to = "Measure",values_to = "Growth")
# chart 4
chartFOUR <- ggplot(growth,aes(Month,Growth,colour = Measure)) +
  geom_line(linewidth = 1) +
  geom_hline(yintercept = 0,linetype = "dashed")+
  labs(title = "Monthly Spending Growth Is Uneven Across Categories",
       subtitle = "Monthly percentage change",x = "",y = "% Change") +
  theme_minimal()
ggplotly(chartFOUR)

CHART 5:

Relationship Between Goods, Services and Total Spending

# get the month data for chart 5
householdData$Year <- year(householdData$Month)
# chart 5
chartFIVE <- ggplot(householdData,aes(x = Goods,y = Services,size = Total,colour = Year)) +
  geom_point(alpha = 0.7) +scale_size_continuous(range = c(2, 12)) +scale_x_continuous(labels = comma) +
  scale_y_continuous(labels = comma) +
  labs(title = "Relationship Between Goods, Services and Total Spending",
    subtitle = "Bubble size represents total household spending",x = "Goods Spending ($ Million)",y = "Services Spending ($ Million)",colour = "Year",size = "Total Spending") +
  theme_minimal()
ggplotly(chartFIVE)