library(shiny)
library(plotly)
## Loading required package: ggplot2
##
## 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(leaflet)
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(ggplot2)
library(shinydashboard)
##
## Attaching package: 'shinydashboard'
## The following object is masked from 'package:graphics':
##
## box
library(tidyr)
```r
library(readr)
data1<- read_csv("Residential property prices, weighted average of eight capital cities, quarterly percentage change.csv")
## Rows: 11 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Date
## dbl (1): RPPI 8 Caps % change
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data2 <- read_csv("BycityResidential property prices, quarterly percentage change, December quarter 2021.csv")
## Rows: 11 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): City
## dbl (1): Quarterly percentage change
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
index_data <- read_csv("Residential Property Price Indexes, capital cities.csv")
## Rows: 45 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Date
## dbl (9): Sydney, Melbourne, Brisbane, Adelaide, Perth, Hobart, Darwin, Canbe...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
vacancy_data <- read_csv("Vacancy_Data.csv")
## Rows: 9 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): City, Sep 2023 Vacancy Rate, Aug 2024 Vacancy Rate, Sep 2024 Vacanc...
## dbl (3): Sep 2023 Vacancies, Aug 2024 Vacancies, Sep 2024 Vacancies
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Total_dwellings_commenced <- read_csv("Total dwellings commenced.csv")
## Rows: 35 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Date
## num (1): Value
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Total_dwellings_completed <- read_csv("Total dwellings completed.csv")
## New names:
## Rows: 35 Columns: 3
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): Date num (1): Value lgl (1): ...3
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...3`
affordability_data <- read_csv("Affordability_index.csv")
## Rows: 34 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (2): Year, Affordability
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
```r
ui <- navbarPage("AUSTRALIA HOUSING CRISIS DASHBOARD",
# Page 1
tabPanel("National overview",
fluidPage(
titlePanel("National trends in residential property prices"),
plotlyOutput("line_chart", height = "500px"),
fluidRow(
column(6, plotlyOutput("national_trend", height = "300px")),
column(6, plotlyOutput("city_trend", height = "300px"))
)
)
),
# Page 2
tabPanel("Supply constraints",
fluidPage(
titlePanel("Impact of low supply on rental and housing Market"),
fluidRow(
column(6, plotlyOutput("vacancy_rate_chart", height = "600px")),
column(6, plotlyOutput("vacancies_trend_chart", height = "600px"))
),
fluidRow(
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon", "↓"),
tags$div(class = "key-metric", "1.2%"),
tags$div(class = "metric-title", "National vacancy rate")
)
),
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon", "↓"),
tags$div(class = "key-metric", "37,932"),
tags$div(class = "metric-title", "Total vacancies (Sep 2024)")
)
),
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon-up", "↓"),
tags$div(class = "key-metric", "39,665"),
tags$div(class = "metric-title", "Total Vacancies (declined compare to Aug 2024)")
)
),
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon", "↓"),
tags$div(class = "key-metric", "Perth, Canberra, Hobart"),
tags$div(class = "metric-title", "Regions with vacancy reduction")
)
)
),
fluidRow(
column(12,
tags$div(
style = "padding-top: 20px;",
tags$p("The shortage of housing supply in Australia has led to significant affordability challenges. Rapid population growth, coupled with evolving housing preferences, has outpaced the rate at which new housing stock is being constructed. This imbalance between supply and demand is impacting the ability of renters and first-time homebuyers to afford housing. Due to the inherent lag in housing supply adjustments, the housing market is experiencing increased prices and reduced affordability.")
)
)
)
)
),
# Page 3
tabPanel("Affordability trends",
fluidPage(
titlePanel("Long-term decline in housing affordability"),
plotlyOutput("affordability_trend_chart", height = "600px"),
fluidRow(
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon", "↓"),
tags$div(class = "key-metric", "16.4x"),
tags$div(class = "metric-title", "Price-to-Income Ratio (Dec 2022)")
)
),
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon-up", "↑"),
tags$div(class = "key-metric", "5%"),
tags$div(class = "metric-title", "Average Dwelling Price Increase (2023)")
)
),
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon", "$167,000"),
tags$div(class = "metric-title", "Increase in Dwelling Price (from 2020)")
)
),
column(3,
div(class = "key-metric-panel",
tags$div(class = "metric-icon", "$33,000"),
tags$div(class = "key-metric", "Additional 20% Deposit Needed")
)
)
),
fluidRow(
column(12,
tags$div(
style = "padding-top: 20px;",
tags$p("Housing affordability has reached a critical stage, where young Australians need only look back a few years to see a time when buying a home was more achievable."),
)
)
)
)
)
)
server <- function(input, output) {
output$line_chart <- renderPlotly({
plot_ly(index_data, x = ~Date) %>%
add_lines(y = ~Sydney, name = "Sydney") %>%
add_lines(y = ~Melbourne, name = "Melbourne") %>%
add_lines(y = ~Brisbane, name = "Brisbane") %>%
add_lines(y = ~Adelaide, name = "Adelaidee") %>%
add_lines(y = ~Perth, name = "Perth") %>%
add_lines(y = ~Hobart, name = "Hobart") %>%
add_lines(y = ~Darwin, name = "Darwin") %>%
add_lines(y = ~Canberra, name = "Canberra") %>%
layout(
title = "Residential property price indexes over time",
xaxis = list(title = "Date"),
yaxis = list(title = "Index number"),
showlegend = TRUE
)
})
output$national_trend <- renderPlotly({
plot_ly(data, x = ~Date, y = ~`RPPI 8 Caps % change`, type = 'bar') %>%
layout(
title = "Quarterly percentage change in residential property prices",
xaxis = list(title = "Date"),
yaxis = list(title = "Percentage change (%)"),
showlegend = FALSE
)
})
output$city_trend <- renderPlotly({
plot_ly(data2, x = ~City, y = ~`Quarterly percentage change`, type = 'bar') %>%
layout(
title = "Quarterly percentage change by city (Dec 2021)",
xaxis = list(title = "City"),
yaxis = list(title = "Percentage change (%)"),
showlegend = FALSE
)
})
# Page 2
output$vacancy_rate_chart <- renderPlotly({
vacancy_rates <- vacancy_data %>%
select(City, `Sep 2023 Vacancy Rate`, `Aug 2024 Vacancy Rate`, `Sep 2024 Vacancy Rate`) %>%
pivot_longer(cols = -City, names_to = "Date", values_to = "VacancyRate")
plot_ly(vacancy_rates, x = ~City, y = ~VacancyRate, color = ~Date, type = 'bar') %>%
layout(
title = "Vacancy rates by city (Sep 2023, Aug 2024, Sep 2024)",
xaxis = list(title = "City"),
yaxis = list(title = "Vacancy rate", tickformat = "%"),
barmode = "group",
showlegend = TRUE
)
})
output$vacancies_trend_chart <- renderPlotly({
vacancies_trend <- vacancy_data %>%
select(City, `Sep 2023 Vacancies`, `Aug 2024 Vacancies`, `Sep 2024 Vacancies`) %>%
pivot_longer(cols = -City, names_to = "Date", values_to = "Vacancies") %>%
mutate(Date = factor(Date, levels = c("Sep 2023 Vacancies", "Aug 2024 Vacancies", "Sep 2024 Vacancies")))
plot_ly(vacancies_trend, x = ~Date, y = ~Vacancies, color = ~City, type = 'scatter', mode = 'lines+markers') %>%
layout(
title = "Trend of vacancies over time by city",
xaxis = list(title = "Date"),
yaxis = list(title = "Number of vacancies"),
showlegend = TRUE
)
})
output$affordability_trend_chart <- renderPlotly({
plot_ly(affordability_data, x = ~Year, y = ~Affordability, type = 'scatter', mode = 'lines') %>%
layout(
title = "Housing affordability index over time",
xaxis = list(title = "year"),
yaxis = list(title = "Affordability"),
showlegend = TRUE
)
})
}
shinyApp(ui = ui, server = server)
Shiny applications not supported in static R Markdown documents
References