The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Create dataset: ons_uk_population_2023

This code is the original written to get and transform the data and is not updated.

Source: ONS

library(readxl)
library(tidyverse)
library(tidyr)

# Load the data in
population_data_2023_f <- read_excel(
  "mye23tablesuk.xlsx", # add full file path here before file name
  sheet = "MYE2 - Females",
  skip = 7
)

population_data_2023_m <- read_excel(
  "mye23tablesuk.xlsx", # add full file path here before file name
  sheet = "MYE2 - Males",
  skip = 7
)

# pivot longer
population_data_2023_f <- population_data_2023_f |>
  select(!`All ages`) |>
  pivot_longer(`0`:`90+`, names_to = "age", values_to = "count")

population_data_2023_m <- population_data_2023_m |>
  select(!`All ages`) |>
  pivot_longer(`0`:`90+`, names_to = "age", values_to = "count")

ons_uk_population_2023 <- bind_rows(
  females = population_data_2023_f,
  males = population_data_2023_m,
  .id = "sex"
)
ons_uk_population_2023 <- ons_uk_population_2023 |>
  janitor::clean_names()

usethis::use_data(ons_uk_population_2023, overwrite = TRUE)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.