Skip to content

Commit 5d73b83

Browse files
committed
Added Scotland ltla population for 2022
1 parent 93fef5d commit 5d73b83

6 files changed

Lines changed: 89 additions & 0 deletions

File tree

R/data.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,24 @@ NULL
470470
#' @source \url{https://ons.gov.uk/}
471471
"population21_ltla21"
472472

473+
#' Population in Scotland Councils, 2022 mid year estimates
474+
#'
475+
#' A data set containing 2022 mid year estimate population counts for each
476+
#' Council in Scotland by sex, age.
477+
#'
478+
#' @format A data frame of class "tbl" with 32 rows and 95 variables:
479+
#' \describe{
480+
#' \item{ltla19_name}{Local Authority name}
481+
#' \item{ltla19_code}{Local Authority code}
482+
#' \item{sex}{Sex}
483+
#' \item{all_ages}{Total number of people}
484+
#' \item{`0`:`90 and over`}{Number of people in each single age group}
485+
486+
#' ...
487+
#' }
488+
#' @source \url{https://www.nrscotland.gov.uk/statistics-and-data/statistics/statistics-by-theme/population/population-estimates/mid-year-population-estimates/mid-2022#:~:text=Of%20the%2032%20council%20areas,and%20Orkney%20Islands%20with%2022%2C020)}
489+
"population22_ltla19_scotland"
490+
473491
#' Proficiency in English for England and Wales from the 2021 Census (MSOA)
474492
#'
475493
#' A data sets containing Census 2021 proficiency in English numbers and

R/sysdata.rda

72 Bytes
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# ---- Load ----
2+
library(tidyverse)
3+
library(devtools)
4+
library(readxl)
5+
library(httr)
6+
library(janitor)
7+
8+
# Load package
9+
load_all(".")
10+
11+
# Set query url
12+
query_url <-
13+
query_urls |>
14+
filter(id == "estimates22_ltla19_scot") |>
15+
pull(query)
16+
17+
GET(
18+
query_url,
19+
write_disk(tf <- tempfile(fileext = ".xlsx"))
20+
)
21+
22+
pop <-
23+
read_excel(
24+
tf,
25+
sheet = "Table 1"
26+
)
27+
28+
population22_ltla19_scotland <- pop |>
29+
row_to_names(row_number = 3) |>
30+
filter(`Area type` == "Council area") |>
31+
filter(Sex == "Persons") |>
32+
rename(
33+
ltla19_name = `Area name`,
34+
ltla19_code = `Area code`,
35+
sex = Sex,
36+
all_ages = `All ages`
37+
) |>
38+
select(!`Area type`)
39+
40+
# Save output to data/ folder
41+
usethis::use_data(population22_ltla19_scotland, overwrite = TRUE)

data-raw/query_urls.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ query_urls <-
4343
"population", "estimates20_utla20", "25.06.21", "OGLv3", "https://www.ons.gov.uk/file?uri=%2fpeoplepopulationandcommunity%2fpopulationandmigration%2fpopulationestimates%2fdatasets%2fpopulationestimatesforukenglandandwalesscotlandandnorthernireland%2fmid2020/ukpopestimatesmid2020on2021geography.xls", "https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/datasets/populationestimatesforukenglandandwalesscotlandandnorthernireland",
4444
"population", "estimates21_ltla21_scot", "13.07.21", "OGLv3", "https://www.nrscotland.gov.uk/files//statistics/population-estimates/mid-21/mid-year-pop-est-21-data.xlsx", "https://www.nrscotland.gov.uk/statistics-and-data/statistics/statistics-by-theme/population/population-estimates/mid-year-population-estimates/mid-2021",
4545
"population", "estimates_hb19", "15.07.22", "OGLv3", "https://www.opendata.nhs.scot/dataset/7f010430-6ce1-4813-b25c-f7f335bdc4dc/resource/27a72cc8-d6d8-430c-8b4f-3109a9ceadb1/download/hb2019_pop_est_15072022.csv", "https://www.opendata.nhs.scot/dataset/population-estimates/resource/27a72cc8-d6d8-430c-8b4f-3109a9ceadb1",
46+
"population", "estimates22_ltla19_scot", "15.07.22", "OGLv3", "https://www.nrscotland.gov.uk/files//statistics/population-estimates/mid-22/mid-year-pop-est-22-data.xlsx", "https://www.nrscotland.gov.uk/statistics-and-data/statistics/statistics-by-theme/population/population-estimates/mid-year-population-estimates/mid-2022#:~:text=Of%20the%2032%20council%20areas,and%20Orkney%20Islands%20with%2022%2C020)",
47+
4648

4749
# - Population estimate OA -
4850
# East Midlands
6.54 KB
Binary file not shown.

man/population22_ltla19_scotland.Rd

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)