We load necessary non-base R libraries.

Download past sales data for three northern Canberra suburbs from the last 5 years.

# Get data for three ACT suburbs from the last 5 years 
suburbs <- c("Watson, ACT", "Ainslie, ACT", "Downer, ACT")
years <- 2018L:2022L
data <- get_past_sales_data(suburbs, years)
#> [2022-09-13 06:31:56] Looking up division ID for suburb='Watson, ACT'...
#> [2022-09-13 06:31:56] URL: https://www.allhomes.com.au/svc/locality/searchallbyname?st=ACT&n=watson
#> [2022-09-13 06:31:57] Finding data for ID=14651, year=2018...
#> [2022-09-13 06:31:57] URL: https://www.allhomes.com.au/ah/research/_/121465112/sale-history?year=2018
#> [2022-09-13 06:32:00] Found 298 entries.
#> [2022-09-13 06:32:00] Finding data for ID=14651, year=2019...
#> [2022-09-13 06:32:00] URL: https://www.allhomes.com.au/ah/research/_/121465112/sale-history?year=2019
#> [2022-09-13 06:32:02] Found 359 entries.
#> [2022-09-13 06:32:02] Finding data for ID=14651, year=2020...
#> [2022-09-13 06:32:02] URL: https://www.allhomes.com.au/ah/research/_/121465112/sale-history?year=2020
#> [2022-09-13 06:32:04] Found 365 entries.
#> [2022-09-13 06:32:04] Finding data for ID=14651, year=2021...
#> [2022-09-13 06:32:04] URL: https://www.allhomes.com.au/ah/research/_/121465112/sale-history?year=2021
#> [2022-09-13 06:32:06] Found 318 entries.
#> [2022-09-13 06:32:06] Finding data for ID=14651, year=2022...
#> [2022-09-13 06:32:06] URL: https://www.allhomes.com.au/ah/research/_/121465112/sale-history?year=2022
#> [2022-09-13 06:32:07] Found 88 entries.
#> [2022-09-13 06:32:07] Looking up division ID for suburb='Ainslie, ACT'...
#> [2022-09-13 06:32:07] URL: https://www.allhomes.com.au/svc/locality/searchallbyname?st=ACT&n=ainslie
#> [2022-09-13 06:32:07] Finding data for ID=14743, year=2018...
#> [2022-09-13 06:32:07] URL: https://www.allhomes.com.au/ah/research/_/121474312/sale-history?year=2018
#> [2022-09-13 06:32:08] Found 104 entries.
#> [2022-09-13 06:32:08] Finding data for ID=14743, year=2019...
#> [2022-09-13 06:32:08] URL: https://www.allhomes.com.au/ah/research/_/121474312/sale-history?year=2019
#> [2022-09-13 06:32:09] Found 98 entries.
#> [2022-09-13 06:32:09] Finding data for ID=14743, year=2020...
#> [2022-09-13 06:32:09] URL: https://www.allhomes.com.au/ah/research/_/121474312/sale-history?year=2020
#> [2022-09-13 06:32:10] Found 95 entries.
#> [2022-09-13 06:32:10] Finding data for ID=14743, year=2021...
#> [2022-09-13 06:32:10] URL: https://www.allhomes.com.au/ah/research/_/121474312/sale-history?year=2021
#> [2022-09-13 06:32:11] Found 106 entries.
#> [2022-09-13 06:32:11] Finding data for ID=14743, year=2022...
#> [2022-09-13 06:32:11] URL: https://www.allhomes.com.au/ah/research/_/121474312/sale-history?year=2022
#> [2022-09-13 06:32:12] Found 31 entries.
#> [2022-09-13 06:32:12] Looking up division ID for suburb='Downer, ACT'...
#> [2022-09-13 06:32:12] URL: https://www.allhomes.com.au/svc/locality/searchallbyname?st=ACT&n=downer
#> [2022-09-13 06:32:13] Finding data for ID=14595, year=2018...
#> [2022-09-13 06:32:13] URL: https://www.allhomes.com.au/ah/research/_/121459512/sale-history?year=2018
#> [2022-09-13 06:32:14] Found 106 entries.
#> [2022-09-13 06:32:14] Finding data for ID=14595, year=2019...
#> [2022-09-13 06:32:14] URL: https://www.allhomes.com.au/ah/research/_/121459512/sale-history?year=2019
#> [2022-09-13 06:32:15] Found 128 entries.
#> [2022-09-13 06:32:15] Finding data for ID=14595, year=2020...
#> [2022-09-13 06:32:15] URL: https://www.allhomes.com.au/ah/research/_/121459512/sale-history?year=2020
#> [2022-09-13 06:32:16] Found 152 entries.
#> [2022-09-13 06:32:16] Finding data for ID=14595, year=2021...
#> [2022-09-13 06:32:16] URL: https://www.allhomes.com.au/ah/research/_/121459512/sale-history?year=2021
#> [2022-09-13 06:32:17] Found 116 entries.
#> [2022-09-13 06:32:17] Finding data for ID=14595, year=2022...
#> [2022-09-13 06:32:17] URL: https://www.allhomes.com.au/ah/research/_/121459512/sale-history?year=2022
#> [2022-09-13 06:32:18] Found 44 entries.

We show the distribution of sale prices as a function of the number of bedrooms.

# Plot
data %>%
    filter(!is.na(bedrooms), bedrooms > 0, price > 0) %>%
    ggplot(aes(as.factor(bedrooms), price)) +
    geom_boxplot() +
    scale_y_continuous(
        labels = scales::label_dollar(scale = 1e-6, suffix = "M")) +
    facet_wrap(~ division) +
    labs(x = "No. of bedrooms", y = "Sales price") +
    theme_minimal()