|
| 1 | +--- |
| 2 | +pagetitle: "Mid-2024 population estimates" |
| 3 | +lang: "en-GB" |
| 4 | +output: |
| 5 | + html_document: |
| 6 | + css: ../../guidance/template/styles.css |
| 7 | + self_contained: TRUE |
| 8 | +--- |
| 9 | + |
| 10 | +```{r setup, include=FALSE} |
| 11 | +knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE) |
| 12 | +library(tidyverse) ; library(htmltools) ; library(DT) |
| 13 | +
|
| 14 | +df <- read_csv("mid-year_2024_population_estimates_ward.csv") %>% |
| 15 | + rename_all(. %>% str_to_title() %>% str_replace_all("_", " ")) %>% |
| 16 | + mutate(`Area name` = factor(`Area name`)) %>% |
| 17 | + rename_all(. %>% str_to_title()) |
| 18 | +``` |
| 19 | +<header> |
| 20 | +<span id="a11yNav"><a href="#downloads" class="themeBlockDark">Skip to downloads</a></span> |
| 21 | +<a href="https://www.trafforddatalab.io/data.html"><img src="https://www.trafforddatalab.io/assets/logo/trafforddatalab_logo.svg" alt="Trafford Data Lab" aria-label="Return to Trafford Data Lab data page" width="100" class="traffordDataLabLogo"/></a> |
| 22 | + |
| 23 | +<h1>Mid-2024 population estimates</h1> |
| 24 | +*Estimates of the usual resident population in Trafford during mid-2024.* |
| 25 | + |
| 26 | +</header> |
| 27 | + |
| 28 | +<main> |
| 29 | +<h2>Metadata</h2> |
| 30 | + |
| 31 | +<table id="metadata" class="table table-condensed"> |
| 32 | + <thead> |
| 33 | + <tr class="header"> |
| 34 | + <th>Source</th> |
| 35 | + <th>Publisher</th> |
| 36 | + <th>Time period</th> |
| 37 | + <th>Geography</th> |
| 38 | + <th>Licence</th> |
| 39 | + <th>Attribution</th> |
| 40 | + <th>Last updated</th> |
| 41 | + </tr> |
| 42 | + </thead> |
| 43 | + <tr> |
| 44 | + <td>Office for National Statistics</td> |
| 45 | + <td><a href="https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/datasets/estimatesofthepopulationforenglandandwales" target="_blank">Office for National Statistics</a></td> |
| 46 | + <td><time datetime="2024-06-30">2024-06-30</time></td> |
| 47 | + <td>Local authority, electoral wards, MSOAs, LSOAs and OAs</td> |
| 48 | + <td><a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" target="_blank">OGL v3.0</a></td> |
| 49 | + <td>Contains public sector information licensed under the Open Government Licence v3.0</td> |
| 50 | + <td><time datetime="2026-03-04">2026-03-04</time></td> |
| 51 | + </tr> |
| 52 | +</table> |
| 53 | + |
| 54 | +<h2>Preview</h2> |
| 55 | +Sort, filter and export a selection of the data using the table. |
| 56 | + |
| 57 | +<div id = "renderDT"> |
| 58 | + |
| 59 | +```{r preview} |
| 60 | +datatable(df, |
| 61 | + class = 'cell-border stripe', |
| 62 | + rownames = FALSE, |
| 63 | + extensions = c('Scroller', 'Buttons', 'KeyTable'), |
| 64 | + options = list( |
| 65 | + keys = TRUE, |
| 66 | + search = list(regex = TRUE), |
| 67 | + searchHighlight = TRUE, |
| 68 | + dom = 'ftB', |
| 69 | + buttons = list( |
| 70 | + list(extend = "csv", |
| 71 | + text = "Download selection")), |
| 72 | + deferRender = TRUE, |
| 73 | + scrollX = TRUE, |
| 74 | + scrollY = 300, |
| 75 | + scroller = TRUE, |
| 76 | + columnDefs = list( |
| 77 | + list(className = 'dt-left', targets = "_all") |
| 78 | + ))) |
| 79 | +``` |
| 80 | +</div> |
| 81 | +<div id="tableFooterTitle">Mid-2024 population estimates for Trafford's wards</div> |
| 82 | + |
| 83 | +<h2>Data</h2> |
| 84 | +<span id ="downloads">Download the complete dataset using the following links:</span> |
| 85 | + |
| 86 | +|File name |Format | |
| 87 | +|---|---| |
| 88 | +|[mid-year_2024_population_estimates_all_geographies.csv](mid-year_2024_population_estimates_all_geographies.csv) |CSV | |
| 89 | +|[mid-year_2024_population_estimates_local_authority.csv](mid-year_2024_population_estimates_local_authority.csv) |CSV | |
| 90 | +|[mid-year_2024_population_estimates_ward.csv](mid-year_2024_population_estimates_ward.csv) |CSV | |
| 91 | +|[mid-year_2024_population_estimates_msoa.csv](mid-year_2024_population_estimates_msoa.csv) |CSV | |
| 92 | +|[mid-year_2024_population_estimates_lsoa.csv](mid-year_2024_population_estimates_lsoa.csv) |CSV | |
| 93 | +|[mid-year_2024_population_estimates_oa.csv](mid-year_2024_population_estimates_oa.csv) |CSV | |
| 94 | + |
| 95 | +<h2>Pre-processing</h2> |
| 96 | +[The R script used to process the data](pre-processing.R) can be adapted to other areas. For information about R visit the <a href="https://cran.r-project.org" target="_blank">CRAN website</a>. |
| 97 | + |
| 98 | +</main> |
| 99 | + |
| 100 | +<script> |
| 101 | + // Fixes to dynamic elements created by DataTables to improve accessibility |
| 102 | + var removeElFn = setInterval(removeElement, 1000); |
| 103 | + |
| 104 | + function removeElement() { |
| 105 | + try { |
| 106 | + var el = document.getElementsByClassName("dataTables_scrollBody")[0].childNodes[0]; |
| 107 | + el.removeChild(el.childNodes[0]); // Remove unwanted hidden text element from table - causing accessibility alert as it has no label |
| 108 | + |
| 109 | + el.parentNode.setAttribute('tabindex', '0'); // add attribute allowing keyboard users to access scrollable area |
| 110 | + |
| 111 | + clearInterval(removeElFn); // cancel any further calls to this function as we have completed all actions |
| 112 | + } |
| 113 | + catch(e) { |
| 114 | + // form element 'el' doesn't exist yet so setInterval will call the function again until it does |
| 115 | + } |
| 116 | + } |
| 117 | +</script> |
0 commit comments