Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jonocarroll/88b86cea90e798668dc25d43d0211180 to your computer and use it in GitHub Desktop.
Save jonocarroll/88b86cea90e798668dc25d43d0211180 to your computer and use it in GitHub Desktop.
geofacet AUS grid example
## AUS population by age
library(geofacet)
library(ggplot2)
library(dplyr)
library(rio)
library(scales)
library(tibble)
## create the AUS grid
aus_grid1 <- tribble(~code, ~row, ~col, ~name,
"WA", 3, 1, "Western Australia",
"NT", 1, 2, "Northern Territory",
"SA", 5, 2, "South Australia",
"QLD", 2, 3, "Queensland",
"NSW", 4, 3, "New South Wales",
"ACT", 5, 3, "Australian Capital Territory",
"VIC", 6, 3, "Victoria",
"TAS", 7, 3, "Tasmania")
# submit_grid(aus_grid1)
## read and clean up the AUS data
## http://lmip.gov.au/default.aspx?LMIP/Downloads/ABSLabourForceRegion
aus_pop <- import("SA4 Population by Age Group - March 2017.csv") %>%
filter(`Region Name` != "Australia") %>%
left_join(aus_grid1, by = c("Region Name" = "name")) %>%
mutate(Population = as.integer(gsub(",", "", Population)))
## plot the grid of populations with facet_geo()
ggplot(aus_pop, aes(`Age Group`, Population/1e6, fill = `Age Group`)) +
geom_col() +
facet_geo(~ code, grid = aus_grid1) +
scale_y_continuous(label = unit_format(unit = "M")) +
labs(title = "Australian Population Breakdown",
caption = "Data Source: ABS Labour Force Survey, 12 month average",
y = "Population [Millions]") +
theme_bw()
Region Name Age Group Population Population Distribution (%)
New South Wales 15 to 24 1,005,900 16.0
New South Wales 25 to 34 1,121,900 17.8
New South Wales 35 to 44 1,028,300 16.3
New South Wales 45 to 54 993,100 15.8
New South Wales 55 to 64 910,900 14.5
New South Wales 65 and over 1,239,900 19.7
Victoria 15 to 24 804,500 16.2
Victoria 25 to 34 939,500 18.9
Victoria 35 to 44 827,600 16.6
Victoria 45 to 54 792,100 15.9
Victoria 55 to 64 689,200 13.8
Victoria 65 and over 925,000 18.6
Queensland 15 to 24 647,700 16.6
Queensland 25 to 34 682,500 17.5
Queensland 35 to 44 642,900 16.5
Queensland 45 to 54 638,800 16.4
Queensland 55 to 64 558,200 14.3
Queensland 65 and over 720,800 18.5
South Australia 15 to 24 216,700 15.4
South Australia 25 to 34 229,400 16.3
South Australia 35 to 44 211,300 15.0
South Australia 45 to 54 228,100 16.2
South Australia 55 to 64 215,000 15.3
South Australia 65 and over 306,200 21.8
Western Australia 15 to 24 337,900 16.0
Western Australia 25 to 34 415,600 19.6
Western Australia 35 to 44 363,300 17.2
Western Australia 45 to 54 347,900 16.4
Western Australia 55 to 64 294,600 13.9
Western Australia 65 and over 357,700 16.9
Tasmania 15 to 24 65,400 15.4
Tasmania 25 to 34 58,400 13.7
Tasmania 35 to 44 60,600 14.2
Tasmania 45 to 54 70,400 16.5
Tasmania 55 to 64 72,300 17.0
Tasmania 65 and over 98,500 23.1
Northern Territory 15 to 24 32,900 17.6
Northern Territory 25 to 34 43,000 23.0
Northern Territory 35 to 44 36,200 19.4
Northern Territory 45 to 54 31,600 16.9
Northern Territory 55 to 64 24,800 13.3
Northern Territory 65 and over 18,100 9.7
Australian Capital Territory 15 to 24 52,500 16.5
Australian Capital Territory 25 to 34 66,800 21.0
Australian Capital Territory 35 to 44 56,500 17.8
Australian Capital Territory 45 to 54 49,700 15.7
Australian Capital Territory 55 to 64 41,800 13.2
Australian Capital Territory 65 and over 50,100 15.8
Australia 15 to 24 3,185,400 16.1
Australia 25 to 34 3,585,700 18.1
Australia 35 to 44 3,237,100 16.4
Australia 45 to 54 3,165,100 16.0
Australia 55 to 64 2,832,400 14.3
Australia 65 and over 3,772,900 19.1
@jonocarroll
Copy link
Author

auspopulation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment