ons_uk_population_2023 | R Documentation |
ONS Population Estimates for Mid-year 2023 National and subnational mid-year population estimates for the UK and its constituent countries by administrative area, age and sex (including components of population change, median age and population density).
data(ons_uk_population_2023)
Tibble with six columns
male or female
country/geography code
country of the UK
Country
year of age
the number of people in this group
ONS Estimates of the population for the UK, England, Wales, Scotland, and Northern Ireland
data(ons_uk_population_2023)
library(dplyr)
library(tidyr)
# create a dataset that has total population by age groups for England
ons_uk_population_2023 |>
filter(Name == "ENGLAND") |>
mutate(age_group = case_when(
as.numeric(age) <= 17 ~ "0-17",
as.numeric(age) >= 18 & as.numeric(age) <= 64 ~ "18-64",
as.numeric(age) >= 65 ~ "65+",
age == "90+" ~ "65+"
)) |>
group_by(age_group) |>
summarise(count = sum(count))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.