{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Social Vulnerability Ireland - Census Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Environment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### R Libraries\n", "Any required R libraries are imported into the kernal:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Load R libraries\n", "## none required" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Output directory" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# create the pipeline directory if it does not exist\n", "pipeline_dir <- file.path(\"../..\",\"2_pipeline\",\"Ireland\",\"1a_CensusData\",\"2022\")\n", "if(!dir.exists(pipeline_dir)){\n", " dir.create(pipeline_dir, recursive = TRUE)\n", " print(paste0(pipeline_dir, \" created\"))\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import the csv data\n", "Ireland census data from: https://www.cso.ie/en/census/census2022/census2022smallareapopulationstatistics" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 795
GUIDGEOGIDGEOGDESCUR_CategoryUR_Category_DescT1_1AGE0MT1_1AGE1MT1_1AGE2MT1_1AGE3MT1_1AGE4MT15_1_2CT15_1_3CT15_1_GE4CT15_1_NSCT15_1_TCT15_2_BBT15_2_OICT15_2_NOT15_2_NST15_2_T
<chr><chr><chr><int><chr><int><int><int><int><int><int><int><int><int><int><int><int><int><int><int>
14c07d11e-11d3-851d-e053-ca3ca8c0ca7f017001001 017001001 44. Rural areas with high urban influence 06110712067135 8037 9 9135
24c07d11e-123a-851d-e053-ca3ca8c0ca7f017002001 017002001 44. Rural areas with high urban influence 12124601462118 901115 2118
34c07d11e-14b1-851d-e053-ca3ca8c0ca7f017002002 017002002 33. Independent urban towns 1512045 733119101 310 5119
4bf640964-28f3-4ccf-a610-04685d80ea2e017002003/01017002003/0144. Rural areas with high urban influence 45114751587157134 311 9157
54c07d11d-f709-851d-e053-ca3ca8c0ca7f017003001 017003001 55. Rural areas with moderate urban influence01111311969 90 50161410 90
64c07d11e-1237-851d-e053-ca3ca8c0ca7f017003002 017003002 55. Rural areas with moderate urban influence02313571168118 851610 7118
\n" ], "text/latex": [ "A data.frame: 6 × 795\n", "\\begin{tabular}{r|lllllllllllllllllllll}\n", " & GUID & GEOGID & GEOGDESC & UR\\_Category & UR\\_Category\\_Desc & T1\\_1AGE0M & T1\\_1AGE1M & T1\\_1AGE2M & T1\\_1AGE3M & T1\\_1AGE4M & ⋯ & T15\\_1\\_2C & T15\\_1\\_3C & T15\\_1\\_GE4C & T15\\_1\\_NSC & T15\\_1\\_TC & T15\\_2\\_BB & T15\\_2\\_OIC & T15\\_2\\_NO & T15\\_2\\_NS & T15\\_2\\_T\\\\\n", " & & & & & & & & & & & ⋯ & & & & & & & & & & \\\\\n", "\\hline\n", "\t1 & 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f & 017001001 & 017001001 & 4 & 4. Rural areas with high urban influence & 0 & 6 & 1 & 1 & 0 & ⋯ & 71 & 20 & 6 & 7 & 135 & 80 & 37 & 9 & 9 & 135\\\\\n", "\t2 & 4c07d11e-123a-851d-e053-ca3ca8c0ca7f & 017002001 & 017002001 & 4 & 4. Rural areas with high urban influence & 1 & 2 & 1 & 2 & 4 & ⋯ & 60 & 14 & 6 & 2 & 118 & 90 & 11 & 15 & 2 & 118\\\\\n", "\t3 & 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f & 017002002 & 017002002 & 3 & 3. Independent urban towns & 1 & 5 & 1 & 2 & 0 & ⋯ & 45 & 7 & 3 & 3 & 119 & 101 & 3 & 10 & 5 & 119\\\\\n", "\t4 & bf640964-28f3-4ccf-a610-04685d80ea2e & 017002003/01 & 017002003/01 & 4 & 4. Rural areas with high urban influence & 4 & 5 & 1 & 1 & 4 & ⋯ & 75 & 15 & 8 & 7 & 157 & 134 & 3 & 11 & 9 & 157\\\\\n", "\t5 & 4c07d11d-f709-851d-e053-ca3ca8c0ca7f & 017003001 & 017003001 & 5 & 5. Rural areas with moderate urban influence & 0 & 1 & 1 & 1 & 1 & ⋯ & 31 & 19 & 6 & 9 & 90 & 50 & 16 & 14 & 10 & 90\\\\\n", "\t6 & 4c07d11e-1237-851d-e053-ca3ca8c0ca7f & 017003002 & 017003002 & 5 & 5. Rural areas with moderate urban influence & 0 & 2 & 3 & 1 & 3 & ⋯ & 57 & 11 & 6 & 8 & 118 & 85 & 16 & 10 & 7 & 118\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 795\n", "\n", "| | GUID <chr> | GEOGID <chr> | GEOGDESC <chr> | UR_Category <int> | UR_Category_Desc <chr> | T1_1AGE0M <int> | T1_1AGE1M <int> | T1_1AGE2M <int> | T1_1AGE3M <int> | T1_1AGE4M <int> | ⋯ ⋯ | T15_1_2C <int> | T15_1_3C <int> | T15_1_GE4C <int> | T15_1_NSC <int> | T15_1_TC <int> | T15_2_BB <int> | T15_2_OIC <int> | T15_2_NO <int> | T15_2_NS <int> | T15_2_T <int> |\n", "|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n", "| 1 | 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f | 017001001 | 017001001 | 4 | 4. Rural areas with high urban influence | 0 | 6 | 1 | 1 | 0 | ⋯ | 71 | 20 | 6 | 7 | 135 | 80 | 37 | 9 | 9 | 135 |\n", "| 2 | 4c07d11e-123a-851d-e053-ca3ca8c0ca7f | 017002001 | 017002001 | 4 | 4. Rural areas with high urban influence | 1 | 2 | 1 | 2 | 4 | ⋯ | 60 | 14 | 6 | 2 | 118 | 90 | 11 | 15 | 2 | 118 |\n", "| 3 | 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f | 017002002 | 017002002 | 3 | 3. Independent urban towns | 1 | 5 | 1 | 2 | 0 | ⋯ | 45 | 7 | 3 | 3 | 119 | 101 | 3 | 10 | 5 | 119 |\n", "| 4 | bf640964-28f3-4ccf-a610-04685d80ea2e | 017002003/01 | 017002003/01 | 4 | 4. Rural areas with high urban influence | 4 | 5 | 1 | 1 | 4 | ⋯ | 75 | 15 | 8 | 7 | 157 | 134 | 3 | 11 | 9 | 157 |\n", "| 5 | 4c07d11d-f709-851d-e053-ca3ca8c0ca7f | 017003001 | 017003001 | 5 | 5. Rural areas with moderate urban influence | 0 | 1 | 1 | 1 | 1 | ⋯ | 31 | 19 | 6 | 9 | 90 | 50 | 16 | 14 | 10 | 90 |\n", "| 6 | 4c07d11e-1237-851d-e053-ca3ca8c0ca7f | 017003002 | 017003002 | 5 | 5. Rural areas with moderate urban influence | 0 | 2 | 3 | 1 | 3 | ⋯ | 57 | 11 | 6 | 8 | 118 | 85 | 16 | 10 | 7 | 118 |\n", "\n" ], "text/plain": [ " GUID GEOGID GEOGDESC UR_Category\n", "1 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f 017001001 017001001 4 \n", "2 4c07d11e-123a-851d-e053-ca3ca8c0ca7f 017002001 017002001 4 \n", "3 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f 017002002 017002002 3 \n", "4 bf640964-28f3-4ccf-a610-04685d80ea2e 017002003/01 017002003/01 4 \n", "5 4c07d11d-f709-851d-e053-ca3ca8c0ca7f 017003001 017003001 5 \n", "6 4c07d11e-1237-851d-e053-ca3ca8c0ca7f 017003002 017003002 5 \n", " UR_Category_Desc T1_1AGE0M T1_1AGE1M T1_1AGE2M\n", "1 4. Rural areas with high urban influence 0 6 1 \n", "2 4. Rural areas with high urban influence 1 2 1 \n", "3 3. Independent urban towns 1 5 1 \n", "4 4. Rural areas with high urban influence 4 5 1 \n", "5 5. Rural areas with moderate urban influence 0 1 1 \n", "6 5. Rural areas with moderate urban influence 0 2 3 \n", " T1_1AGE3M T1_1AGE4M ⋯ T15_1_2C T15_1_3C T15_1_GE4C T15_1_NSC T15_1_TC\n", "1 1 0 ⋯ 71 20 6 7 135 \n", "2 2 4 ⋯ 60 14 6 2 118 \n", "3 2 0 ⋯ 45 7 3 3 119 \n", "4 1 4 ⋯ 75 15 8 7 157 \n", "5 1 1 ⋯ 31 19 6 9 90 \n", "6 1 3 ⋯ 57 11 6 8 118 \n", " T15_2_BB T15_2_OIC T15_2_NO T15_2_NS T15_2_T\n", "1 80 37 9 9 135 \n", "2 90 11 15 2 118 \n", "3 101 3 10 5 119 \n", "4 134 3 11 9 157 \n", "5 50 16 14 10 90 \n", "6 85 16 10 7 118 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Read the census data\n", "census_data <- read.csv('../../0_data/census/Ireland/2022/SAPS_2022_Small_Area_UR_171024.csv', sep=\",\")\n", "\n", "# remove 'IE0' row from Census 2022 CSV supplied by CSO, and reindex\n", "census_data <- census_data[census_data$GUID != \"IE0\", ]\n", "row.names(census_data) <- 1:nrow(census_data)\n", "\n", "head(census_data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Prepare data\n", "We only require a subset of the census data for our purposes. We therefore need to extract the relevant data, then combine these to create our vulnerability indicators.\n", "\n", "In addition, the raw data is not suitable for use within the vulnerabiltiy assessment. It needs to be normalised based on the number of people/households within each small area. Therefore, the data is converted to percentages based on the total persons/households within each small area." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Supporting data" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Code that uniquely identifies the census area" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "18919" ], "text/latex": [ "18919" ], "text/markdown": [ "18919" ], "text/plain": [ "[1] 18919" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "identifier <- c('GUID')\n", "census_area_id <- census_data[, identifier, drop = FALSE]\n", "\n", "# number of rows in the census data\n", "head( nrow(census_data) )" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Population total" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 1
population_total
<int>
1419
2345
3338
4439
5255
6344
\n" ], "text/latex": [ "A data.frame: 6 × 1\n", "\\begin{tabular}{r|l}\n", " & population\\_total\\\\\n", " & \\\\\n", "\\hline\n", "\t1 & 419\\\\\n", "\t2 & 345\\\\\n", "\t3 & 338\\\\\n", "\t4 & 439\\\\\n", "\t5 & 255\\\\\n", "\t6 & 344\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 1\n", "\n", "| | population_total <int> |\n", "|---|---|\n", "| 1 | 419 |\n", "| 2 | 345 |\n", "| 3 | 338 |\n", "| 4 | 439 |\n", "| 5 | 255 |\n", "| 6 | 344 |\n", "\n" ], "text/plain": [ " population_total\n", "1 419 \n", "2 345 \n", "3 338 \n", "4 439 \n", "5 255 \n", "6 344 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "population_total <- census_data[, 'T1_1AGETT', drop = FALSE]\n", "names(population_total)[1] <- 'population_total'\n", "head(population_total)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "#### Households / families total" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 1
households_total
<int>
1137
2118
3119
4158
5 91
6119
\n" ], "text/latex": [ "A data.frame: 6 × 1\n", "\\begin{tabular}{r|l}\n", " & households\\_total\\\\\n", " & \\\\\n", "\\hline\n", "\t1 & 137\\\\\n", "\t2 & 118\\\\\n", "\t3 & 119\\\\\n", "\t4 & 158\\\\\n", "\t5 & 91\\\\\n", "\t6 & 119\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 1\n", "\n", "| | households_total <int> |\n", "|---|---|\n", "| 1 | 137 |\n", "| 2 | 118 |\n", "| 3 | 119 |\n", "| 4 | 158 |\n", "| 5 | 91 |\n", "| 6 | 119 |\n", "\n" ], "text/plain": [ " households_total\n", "1 137 \n", "2 118 \n", "3 119 \n", "4 158 \n", "5 91 \n", "6 119 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "households_total <- census_data[, 'T5_1T_H', drop = FALSE]\n", "names(households_total)[1] <- 'households_total'\n", "head(households_total)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Domain data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Age domain" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 2
early_childhood_pctage_middle_to_oldest_old_pct
<dbl><dbl>
16.443914 4.534606
26.08695711.014493
35.621302 3.550296
48.883827 8.883827
56.274510 5.098039
67.267442 8.139535
\n" ], "text/latex": [ "A data.frame: 6 × 2\n", "\\begin{tabular}{r|ll}\n", " & early\\_childhood\\_pct & age\\_middle\\_to\\_oldest\\_old\\_pct\\\\\n", " & & \\\\\n", "\\hline\n", "\t1 & 6.443914 & 4.534606\\\\\n", "\t2 & 6.086957 & 11.014493\\\\\n", "\t3 & 5.621302 & 3.550296\\\\\n", "\t4 & 8.883827 & 8.883827\\\\\n", "\t5 & 6.274510 & 5.098039\\\\\n", "\t6 & 7.267442 & 8.139535\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 2\n", "\n", "| | early_childhood_pct <dbl> | age_middle_to_oldest_old_pct <dbl> |\n", "|---|---|---|\n", "| 1 | 6.443914 | 4.534606 |\n", "| 2 | 6.086957 | 11.014493 |\n", "| 3 | 5.621302 | 3.550296 |\n", "| 4 | 8.883827 | 8.883827 |\n", "| 5 | 6.274510 | 5.098039 |\n", "| 6 | 7.267442 | 8.139535 |\n", "\n" ], "text/plain": [ " early_childhood_pct age_middle_to_oldest_old_pct\n", "1 6.443914 4.534606 \n", "2 6.086957 11.014493 \n", "3 5.621302 3.550296 \n", "4 8.883827 8.883827 \n", "5 6.274510 5.098039 \n", "6 7.267442 8.139535 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Age ###\n", "\n", "#TODO: INCLUDE Age 5\n", "# Age - early childhood (0 to 5 yeards old)\n", "early_childhood_fields <- c(\n", " 'T1_1AGE0T', # Age 0 - Total\n", " 'T1_1AGE1T', # Age 1 - Total\n", " 'T1_1AGE2T', # Age 2 - Total\n", " 'T1_1AGE3T', # Age 3 - Total\n", " 'T1_1AGE4T', # Age 4 - Total\n", " 'T1_1AGE5T' # Age 5 - Total\n", ")\n", "early_childhood_data <- census_data[, early_childhood_fields, drop = FALSE]\n", "early_childhood <- rowSums(early_childhood_data, na.rm=TRUE)\n", "early_childhood_pct <- (early_childhood / population_total) * 100.0\n", "names(early_childhood_pct)[1] <- 'early_childhood_pct'\n", "\n", "# Age - middle to oldest old (75+ years old)\n", "age_middle_to_oldest_old_fields <- c(\n", " 'T1_1AGE75_79T', # Age 75 - 79 - Total\n", " 'T1_1AGE80_84T', # Age 80 - 84 - Total\n", " 'T1_1AGEGE_85T' # Age 85 and over - Total\n", ")\n", "age_middle_to_oldest_old_data <- census_data[, age_middle_to_oldest_old_fields, drop = FALSE]\n", "age_middle_to_oldest_old <- rowSums(age_middle_to_oldest_old_data, na.rm=TRUE)\n", "age_middle_to_oldest_old_pct <- (age_middle_to_oldest_old / population_total) * 100.0\n", "names(age_middle_to_oldest_old_pct)[1] <- 'age_middle_to_oldest_old_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "age_domain_pct <- cbind(early_childhood_pct,\n", " age_middle_to_oldest_old_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(age_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Health domain" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 2
poor_health_pctdisability_pct
<dbl><dbl>
11.67064419.09308
22.02898625.50725
33.55029623.66864
42.27790420.95672
51.96078416.47059
62.61627927.32558
\n" ], "text/latex": [ "A data.frame: 6 × 2\n", "\\begin{tabular}{r|ll}\n", " & poor\\_health\\_pct & disability\\_pct\\\\\n", " & & \\\\\n", "\\hline\n", "\t1 & 1.670644 & 19.09308\\\\\n", "\t2 & 2.028986 & 25.50725\\\\\n", "\t3 & 3.550296 & 23.66864\\\\\n", "\t4 & 2.277904 & 20.95672\\\\\n", "\t5 & 1.960784 & 16.47059\\\\\n", "\t6 & 2.616279 & 27.32558\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 2\n", "\n", "| | poor_health_pct <dbl> | disability_pct <dbl> |\n", "|---|---|---|\n", "| 1 | 1.670644 | 19.09308 |\n", "| 2 | 2.028986 | 25.50725 |\n", "| 3 | 3.550296 | 23.66864 |\n", "| 4 | 2.277904 | 20.95672 |\n", "| 5 | 1.960784 | 16.47059 |\n", "| 6 | 2.616279 | 27.32558 |\n", "\n" ], "text/plain": [ " poor_health_pct disability_pct\n", "1 1.670644 19.09308 \n", "2 2.028986 25.50725 \n", "3 3.550296 23.66864 \n", "4 2.277904 20.95672 \n", "5 1.960784 16.47059 \n", "6 2.616279 27.32558 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Health ###\n", "\n", "# Health - poor health\n", "## Irish census choice of: very good, good, fair, bad, very bad, and not stated\n", "poor_health_fields <- c(\n", " 'T12_3_BT', # Bad - Total\n", " 'T12_3_VBT' # Very bad - Total\n", ")\n", "poor_health_data <- census_data[, poor_health_fields, drop = FALSE]\n", "poor_health <- rowSums(poor_health_data, na.rm=TRUE)\n", "poor_health_pct <- (poor_health / population_total) * 100.0\n", "names(poor_health_pct)[1] <- 'poor_health_pct'\n", "\n", "# Health - disability\n", "disability_fields <- c(\n", " 'T12_1_T' # Persons with disability - Total\n", ")\n", "disability_data <- census_data[, disability_fields, drop = FALSE]\n", "disability <- rowSums(disability_data, na.rm=TRUE)\n", "disability_pct <- (disability / population_total) * 100.0\n", "names(disability_pct)[1] <- 'disability_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "health_domain_pct <- cbind(poor_health_pct,\n", " disability_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(health_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Income domain" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 5
one_parent_households_pctthree_or_more_children_households_pctlow_skilled_employment_pctfarmers_pctunemployment_pct
<dbl><dbl><dbl><dbl><dbl>
1 6.56934316.78832123.6276814.081146 8.830549
2 8.47457612.71186417.10145 9.56521711.884058
314.285714 9.24369715.97633 0.59171613.609467
4 7.594937 7.59493712.98405 4.10022812.300683
5 8.79120913.18681316.8627512.94117611.764706
6 8.40336114.28571427.0348812.20930215.697674
\n" ], "text/latex": [ "A data.frame: 6 × 5\n", "\\begin{tabular}{r|lllll}\n", " & one\\_parent\\_households\\_pct & three\\_or\\_more\\_children\\_households\\_pct & low\\_skilled\\_employment\\_pct & farmers\\_pct & unemployment\\_pct\\\\\n", " & & & & & \\\\\n", "\\hline\n", "\t1 & 6.569343 & 16.788321 & 23.62768 & 14.081146 & 8.830549\\\\\n", "\t2 & 8.474576 & 12.711864 & 17.10145 & 9.565217 & 11.884058\\\\\n", "\t3 & 14.285714 & 9.243697 & 15.97633 & 0.591716 & 13.609467\\\\\n", "\t4 & 7.594937 & 7.594937 & 12.98405 & 4.100228 & 12.300683\\\\\n", "\t5 & 8.791209 & 13.186813 & 16.86275 & 12.941176 & 11.764706\\\\\n", "\t6 & 8.403361 & 14.285714 & 27.03488 & 12.209302 & 15.697674\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 5\n", "\n", "| | one_parent_households_pct <dbl> | three_or_more_children_households_pct <dbl> | low_skilled_employment_pct <dbl> | farmers_pct <dbl> | unemployment_pct <dbl> |\n", "|---|---|---|---|---|---|\n", "| 1 | 6.569343 | 16.788321 | 23.62768 | 14.081146 | 8.830549 |\n", "| 2 | 8.474576 | 12.711864 | 17.10145 | 9.565217 | 11.884058 |\n", "| 3 | 14.285714 | 9.243697 | 15.97633 | 0.591716 | 13.609467 |\n", "| 4 | 7.594937 | 7.594937 | 12.98405 | 4.100228 | 12.300683 |\n", "| 5 | 8.791209 | 13.186813 | 16.86275 | 12.941176 | 11.764706 |\n", "| 6 | 8.403361 | 14.285714 | 27.03488 | 12.209302 | 15.697674 |\n", "\n" ], "text/plain": [ " one_parent_households_pct three_or_more_children_households_pct\n", "1 6.569343 16.788321 \n", "2 8.474576 12.711864 \n", "3 14.285714 9.243697 \n", "4 7.594937 7.594937 \n", "5 8.791209 13.186813 \n", "6 8.403361 14.285714 \n", " low_skilled_employment_pct farmers_pct unemployment_pct\n", "1 23.62768 14.081146 8.830549 \n", "2 17.10145 9.565217 11.884058 \n", "3 15.97633 0.591716 13.609467 \n", "4 12.98405 4.100228 12.300683 \n", "5 16.86275 12.941176 11.764706 \n", "6 27.03488 12.209302 15.697674 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Income ###\n", "\n", "# One parent households\n", "one_parent_households_fields <- c(\n", " 'T5_1OPFC_H', # One parent family (father) with children households (No. of households)\n", " 'T5_1OPMC_H', # One parent family (mother) and children households (No. of households)\n", " 'T5_1OPFCO_H',# One parent family (father) with children and others households (No. of households)\n", " 'T5_1OPMCO_H' # One parent family (mother) with children and others households (No. of households)\n", ")\n", "one_parent_households_data <- census_data[, one_parent_households_fields, drop = FALSE]\n", "one_parent_households <- rowSums(one_parent_households_data, na.rm=TRUE)\n", "one_parent_households_pct <- (one_parent_households / households_total) * 100.0\n", "names(one_parent_households_pct)[1] <- 'one_parent_households_pct'\n", "\n", "# Three or more children per household\n", "#TODO\n", "## For census purposes, a family is defined as a couple with or without children, or a one parent family with one or more children.\n", "## Family members must be usual residents of the relevant household.\n", "## Note: Families can include children aged 18 years (now adults) and over living with their parents\n", "## Dividing by total households, not total families\n", "## Total households = family households + one-person households + non-family households\n", "## Would these be better, children ?:\n", "## T4_2_3CU15\tFamiles with 3 children - All children aged under 15\n", "## T4_2_4CU15\tFamilies with 4 children - All children aged under 15\n", "## T4_2_GE5CU15\tFamilies with 5 or more children - All children aged under 15\n", "three_or_more_children_households_fields <- c(\n", " 'T4_2_3CT', # Families with 3 children - Total\n", " 'T4_2_4CT', # Families with 4 children - Total\n", " 'T4_2_GE5CT' # Families with 5+ children - Total\n", ")\n", "three_or_more_children_households_data <- census_data[, three_or_more_children_households_fields, drop = FALSE]\n", "three_or_more_children_households <- rowSums(three_or_more_children_households_data, na.rm=TRUE)\n", "three_or_more_children_households_pct <- (three_or_more_children_households / households_total) * 100.0\n", "names(three_or_more_children_households_pct)[1] <- 'three_or_more_children_households_pct'\n", "\n", "# Low skilled employment\n", "low_skilled_employment_fields <- c('T9_2_PE', #E Manual skilled (No. of persons)\n", " 'T9_2_PF', #F Semi-skilled (No. of persons)\n", " 'T9_2_PG' #G Unskilled (No. of persons)\n", ")\n", "low_skilled_employment_data <- census_data[, low_skilled_employment_fields, drop = FALSE]\n", "low_skilled_employment <- rowSums(low_skilled_employment_data, na.rm=TRUE)\n", "low_skilled_employment_pct <- (low_skilled_employment / population_total) * 100.0\n", "names(low_skilled_employment_pct)[1] <- 'low_skilled_employment_pct'\n", "\n", "# Farmers\n", "farmers_fields <- c(\n", " 'T9_2_PI' # Farmers (No. of persons)\n", " #'T9_2_PJ' # Agricultural workers (No. of persons) Forestry and fishing also included\n", ")\n", "farmers_data <- census_data[, farmers_fields, drop = FALSE]\n", "farmers <- rowSums(farmers_data, na.rm=TRUE)\n", "farmers_pct <- (farmers / population_total) * 100.0\n", "names(farmers_pct)[1] <- 'farmers_pct'\n", "\n", "# Unemployment\n", "unemployment_fields <- c(\n", " 'T8_1_LFFJT', # Looking for first regular job - Total\n", " 'T8_1_STUT', # Short term unemployed - Total \n", " 'T8_1_LTUT', # Long term unemployed - Total\n", " 'T8_1_LAHFT', # Looking after home/family - Total (NOT SURE ABOUT THIS ONE)\n", " 'T8_1_UTWSDT' # Unable to work due to permanent sickness or disability - Total (MAY CORRELATE WITH HEALTH TOO MUCH)\n", ")\n", "unemployment_data <- census_data[, unemployment_fields, drop = FALSE]\n", "unemployment <- rowSums(unemployment_data, na.rm=TRUE)\n", "unemployment_pct <- (unemployment / population_total) * 100.0\n", "names(unemployment_pct)[1] <- 'unemployment_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "income_domain_pct <- cbind(one_parent_households_pct,\n", " three_or_more_children_households_pct,\n", " low_skilled_employment_pct,\n", " farmers_pct,\n", " unemployment_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(income_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Information Access/Use domain" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 3
no_higher_education_pctspeak_english_pctno_internet_pct
<dbl><dbl><dbl>
10.71599050.4773270 6.569343
20.28985510.289855112.711864
30.88757400.5917160 8.403361
40.45558090.6833713 6.962025
50.39215690.000000015.384615
62.90697670.5813953 8.403361
\n" ], "text/latex": [ "A data.frame: 6 × 3\n", "\\begin{tabular}{r|lll}\n", " & no\\_higher\\_education\\_pct & speak\\_english\\_pct & no\\_internet\\_pct\\\\\n", " & & & \\\\\n", "\\hline\n", "\t1 & 0.7159905 & 0.4773270 & 6.569343\\\\\n", "\t2 & 0.2898551 & 0.2898551 & 12.711864\\\\\n", "\t3 & 0.8875740 & 0.5917160 & 8.403361\\\\\n", "\t4 & 0.4555809 & 0.6833713 & 6.962025\\\\\n", "\t5 & 0.3921569 & 0.0000000 & 15.384615\\\\\n", "\t6 & 2.9069767 & 0.5813953 & 8.403361\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 3\n", "\n", "| | no_higher_education_pct <dbl> | speak_english_pct <dbl> | no_internet_pct <dbl> |\n", "|---|---|---|---|\n", "| 1 | 0.7159905 | 0.4773270 | 6.569343 |\n", "| 2 | 0.2898551 | 0.2898551 | 12.711864 |\n", "| 3 | 0.8875740 | 0.5917160 | 8.403361 |\n", "| 4 | 0.4555809 | 0.6833713 | 6.962025 |\n", "| 5 | 0.3921569 | 0.0000000 | 15.384615 |\n", "| 6 | 2.9069767 | 0.5813953 | 8.403361 |\n", "\n" ], "text/plain": [ " no_higher_education_pct speak_english_pct no_internet_pct\n", "1 0.7159905 0.4773270 6.569343 \n", "2 0.2898551 0.2898551 12.711864 \n", "3 0.8875740 0.5917160 8.403361 \n", "4 0.4555809 0.6833713 6.962025 \n", "5 0.3921569 0.0000000 15.384615 \n", "6 2.9069767 0.5813953 8.403361 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Information Access/Use ###\n", "\n", "# No higher education\n", "no_higher_education_fields <- c(\n", " 'T10_4_NFT' # No formal education - Total\n", " #'T10_4_PT' # Primary education - Total\n", ")\n", "no_higher_education_data <- census_data[, no_higher_education_fields, drop = FALSE]\n", "no_higher_education <- rowSums(no_higher_education_data, na.rm=TRUE)\n", "no_higher_education_pct <- (no_higher_education / population_total) * 100.0\n", "names(no_higher_education_pct)[1] <- 'no_higher_education_pct'\n", "\n", "# Speakers of foreign languages ability to speak English\n", "speak_english_fields <- c(\n", " 'T2_6NW', # Not well\n", " 'T2_6NAA' # Not at all\n", ")\n", "speak_english_data <- census_data[, speak_english_fields, drop = FALSE]\n", "speak_english <- rowSums(speak_english_data, na.rm=TRUE)\n", "speak_english_pct <- (speak_english / population_total) * 100.0\n", "names(speak_english_pct)[1] <- 'speak_english_pct'\n", "\n", "# Households with no Internet connection\n", "no_internet_fields <- c(\n", " 'T15_2_NO'# No internet connection\n", ")\n", "no_internet_data <- census_data[, no_internet_fields, drop = FALSE]\n", "no_internet <- rowSums(no_internet_data, na.rm=TRUE)\n", "no_internet_pct <- (no_internet / households_total) * 100.0\n", "names(no_internet_pct)[1] <- 'no_internet_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "info_domain_pct <- cbind(no_higher_education_pct,\n", " speak_english_pct,\n", " no_internet_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(info_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Local knowledge domain" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 2
new_residents_pctforeign_nationals_pct
<dbl><dbl>
11.9093079 4.773270
20.8695652 5.797101
31.183432013.609467
43.4168565 7.517084
52.3529412 7.843137
63.1976744 8.139535
\n" ], "text/latex": [ "A data.frame: 6 × 2\n", "\\begin{tabular}{r|ll}\n", " & new\\_residents\\_pct & foreign\\_nationals\\_pct\\\\\n", " & & \\\\\n", "\\hline\n", "\t1 & 1.9093079 & 4.773270\\\\\n", "\t2 & 0.8695652 & 5.797101\\\\\n", "\t3 & 1.1834320 & 13.609467\\\\\n", "\t4 & 3.4168565 & 7.517084\\\\\n", "\t5 & 2.3529412 & 7.843137\\\\\n", "\t6 & 3.1976744 & 8.139535\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 2\n", "\n", "| | new_residents_pct <dbl> | foreign_nationals_pct <dbl> |\n", "|---|---|---|\n", "| 1 | 1.9093079 | 4.773270 |\n", "| 2 | 0.8695652 | 5.797101 |\n", "| 3 | 1.1834320 | 13.609467 |\n", "| 4 | 3.4168565 | 7.517084 |\n", "| 5 | 2.3529412 | 7.843137 |\n", "| 6 | 3.1976744 | 8.139535 |\n", "\n" ], "text/plain": [ " new_residents_pct foreign_nationals_pct\n", "1 1.9093079 4.773270 \n", "2 0.8695652 5.797101 \n", "3 1.1834320 13.609467 \n", "4 3.4168565 7.517084 \n", "5 2.3529412 7.843137 \n", "6 3.1976744 8.139535 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Local Knowledge ###\n", "\n", "# New residents - Usually resident population aged 1 year and over by usual residence 1 year before Census Day\n", "new_residents_fields <- c(\n", " 'T2_3EI', # Elsewhere in Ireland\n", " 'T2_3OI' # Outside Ireland\n", ")\n", "new_residents_data <- census_data[, new_residents_fields, drop = FALSE]\n", "new_residents <- rowSums(new_residents_data, na.rm=TRUE)\n", "new_residents_pct <- (new_residents / population_total) * 100.0\n", "names(new_residents_pct)[1] <- 'new_residents_pct'\n", "\n", "# Foreigners - foreign nationals (born outside Ireland)\n", "birthplace_total <- census_data[, 'T2_1TBP', drop = FALSE] # T2_1TBP: Total - Birthplace\n", "birthplace_ireland <- -census_data[, 'T2_1IEBP', drop = FALSE] # T2_1IEBP: Ireland - Birthplace (made negative)\n", "foreign_nationals_data <- data.frame(birthplace_total, birthplace_ireland)\n", "foreign_nationals <- rowSums(foreign_nationals_data, na.rm=TRUE)\n", "foreign_nationals_pct <- (foreign_nationals / population_total) * 100.0\n", "names(foreign_nationals_pct)[1] <- 'foreign_nationals_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "local_knowledge_domain_pct <- cbind(new_residents_pct,\n", " foreign_nationals_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(local_knowledge_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Mobility domain" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 1
no_car_pct
<dbl>
12.919708
24.237288
32.521008
43.797468
51.098901
61.680672
\n" ], "text/latex": [ "A data.frame: 6 × 1\n", "\\begin{tabular}{r|l}\n", " & no\\_car\\_pct\\\\\n", " & \\\\\n", "\\hline\n", "\t1 & 2.919708\\\\\n", "\t2 & 4.237288\\\\\n", "\t3 & 2.521008\\\\\n", "\t4 & 3.797468\\\\\n", "\t5 & 1.098901\\\\\n", "\t6 & 1.680672\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 1\n", "\n", "| | no_car_pct <dbl> |\n", "|---|---|\n", "| 1 | 2.919708 |\n", "| 2 | 4.237288 |\n", "| 3 | 2.521008 |\n", "| 4 | 3.797468 |\n", "| 5 | 1.098901 |\n", "| 6 | 1.680672 |\n", "\n" ], "text/plain": [ " no_car_pct\n", "1 2.919708 \n", "2 4.237288 \n", "3 2.521008 \n", "4 3.797468 \n", "5 1.098901 \n", "6 1.680672 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Mobility ###\n", "\n", "# Households with no motor car\n", "no_car_fields <- c(\n", " 'T15_1_NC' # No motor car\n", ")\n", "no_car_data <- census_data[, no_car_fields, drop = FALSE]\n", "no_car <- rowSums(no_car_data, na.rm=TRUE)\n", "no_car_pct <- (no_car / households_total) * 100.0\n", "names(no_car_pct)[1] <- 'no_car_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "mobility_domain_pct <- cbind(no_car_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(mobility_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Physical access domain" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 1
journey_time_pct
<dbl>
17.159905
26.376812
35.621302
43.644647
56.274510
68.139535
\n" ], "text/latex": [ "A data.frame: 6 × 1\n", "\\begin{tabular}{r|l}\n", " & journey\\_time\\_pct\\\\\n", " & \\\\\n", "\\hline\n", "\t1 & 7.159905\\\\\n", "\t2 & 6.376812\\\\\n", "\t3 & 5.621302\\\\\n", "\t4 & 3.644647\\\\\n", "\t5 & 6.274510\\\\\n", "\t6 & 8.139535\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 1\n", "\n", "| | journey_time_pct <dbl> |\n", "|---|---|\n", "| 1 | 7.159905 |\n", "| 2 | 6.376812 |\n", "| 3 | 5.621302 |\n", "| 4 | 3.644647 |\n", "| 5 | 6.274510 |\n", "| 6 | 8.139535 |\n", "\n" ], "text/plain": [ " journey_time_pct\n", "1 7.159905 \n", "2 6.376812 \n", "3 5.621302 \n", "4 3.644647 \n", "5 6.274510 \n", "6 8.139535 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Physical access ###\n", "\n", "# Journey time - Population aged 5 years and over by journey time to work, school or college \n", "journey_time_fields <- c(\n", " 'T11_3_D5', #1 hour - under 1 1/2 hours\n", " 'T11_3_D6' #1 1/2 hours and over\n", ")\n", "journey_time_data <- census_data[, journey_time_fields, drop = FALSE]\n", "journey_time <- rowSums(journey_time_data, na.rm=TRUE)\n", "journey_time_pct <- (journey_time / population_total) * 100.0\n", "names(journey_time_pct)[1] <- 'journey_time_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "physical_access_domain_pct <- cbind(journey_time_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(physical_access_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Tenure domain" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 1
rented_pct
<dbl>
1 5.250597
2 6.086957
324.852071
4 9.794989
5 3.529412
6 9.883721
\n" ], "text/latex": [ "A data.frame: 6 × 1\n", "\\begin{tabular}{r|l}\n", " & rented\\_pct\\\\\n", " & \\\\\n", "\\hline\n", "\t1 & 5.250597\\\\\n", "\t2 & 6.086957\\\\\n", "\t3 & 24.852071\\\\\n", "\t4 & 9.794989\\\\\n", "\t5 & 3.529412\\\\\n", "\t6 & 9.883721\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 1\n", "\n", "| | rented_pct <dbl> |\n", "|---|---|\n", "| 1 | 5.250597 |\n", "| 2 | 6.086957 |\n", "| 3 | 24.852071 |\n", "| 4 | 9.794989 |\n", "| 5 | 3.529412 |\n", "| 6 | 9.883721 |\n", "\n" ], "text/plain": [ " rented_pct\n", "1 5.250597 \n", "2 6.086957 \n", "3 24.852071 \n", "4 9.794989 \n", "5 3.529412 \n", "6 9.883721 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Tenure ###\n", "\n", "# Permanent private households by type of occupancy \n", "rented_fields <- c(\n", " 'T6_3_RPLP', #Rented from private landlord (No. of persons) \n", " 'T6_3_RLAP', #Rented from Local Authority (No. of persons)\n", " 'T6_3_RVCHBP' #Rented from voluntary/co-operative housing body (No. of persons)\n", ")\n", "rented_data <- census_data[, rented_fields, drop = FALSE]\n", "rented <- rowSums(rented_data, na.rm=TRUE)\n", "rented_pct <- (rented / population_total) * 100.0\n", "names(rented_pct)[1] <- 'rented_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "tenure_domain_pct <- cbind(rented_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(tenure_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Social Network domain data" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 3
not_volunteers_pctprimary_school_age_pctone_person_households_pct
<dbl><dbl><dbl>
187.3508414.0811515.32847
279.7101411.3043514.40678
383.7278113.0177519.32773
482.2323512.9840522.15190
583.9215713.3333321.97802
681.1046512.7907016.80672
\n" ], "text/latex": [ "A data.frame: 6 × 3\n", "\\begin{tabular}{r|lll}\n", " & not\\_volunteers\\_pct & primary\\_school\\_age\\_pct & one\\_person\\_households\\_pct\\\\\n", " & & & \\\\\n", "\\hline\n", "\t1 & 87.35084 & 14.08115 & 15.32847\\\\\n", "\t2 & 79.71014 & 11.30435 & 14.40678\\\\\n", "\t3 & 83.72781 & 13.01775 & 19.32773\\\\\n", "\t4 & 82.23235 & 12.98405 & 22.15190\\\\\n", "\t5 & 83.92157 & 13.33333 & 21.97802\\\\\n", "\t6 & 81.10465 & 12.79070 & 16.80672\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 3\n", "\n", "| | not_volunteers_pct <dbl> | primary_school_age_pct <dbl> | one_person_households_pct <dbl> |\n", "|---|---|---|---|\n", "| 1 | 87.35084 | 14.08115 | 15.32847 |\n", "| 2 | 79.71014 | 11.30435 | 14.40678 |\n", "| 3 | 83.72781 | 13.01775 | 19.32773 |\n", "| 4 | 82.23235 | 12.98405 | 22.15190 |\n", "| 5 | 83.92157 | 13.33333 | 21.97802 |\n", "| 6 | 81.10465 | 12.79070 | 16.80672 |\n", "\n" ], "text/plain": [ " not_volunteers_pct primary_school_age_pct one_person_households_pct\n", "1 87.35084 14.08115 15.32847 \n", "2 79.71014 11.30435 14.40678 \n", "3 83.72781 13.01775 19.32773 \n", "4 82.23235 12.98405 22.15190 \n", "5 83.92157 13.33333 21.97802 \n", "6 81.10465 12.79070 16.80672 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain:Social Network ###\n", "\n", "# Not volunteers\n", "volunteers_fields <- c(\n", " 'T7_1_VOL' # Number of volunteers\n", ")\n", "volunteers_data <- census_data[, volunteers_fields, drop = FALSE]\n", "volunteers <- rowSums(volunteers_data, na.rm=TRUE)\n", "not_volunteers = population_total - volunteers\n", "not_volunteers_pct <- (not_volunteers / population_total) * 100.0\n", "names(not_volunteers_pct)[1] <- 'not_volunteers_pct'\n", "\n", "# Primary school age children\n", "primary_school_age_fields <- c(\n", " 'T1_1AGE4T', #Age 4 - Total\n", " 'T1_1AGE5T', #Age 5 - Total\n", " 'T1_1AGE6T', #Age 6 - Total\n", " 'T1_1AGE7T', #Age 7 - Total\n", " 'T1_1AGE8T', #Age 8 - Total\n", " 'T1_1AGE9T', #Age 9 - Total\n", " 'T1_1AGE10T', #Age 10 - Total\n", " 'T1_1AGE11T', #Age 11 - Total\n", " 'T1_1AGE12T' #Age 12 - Total\n", ")\n", "primary_school_age_data <- census_data[, primary_school_age_fields, drop = FALSE]\n", "primary_school_age <- rowSums(primary_school_age_data, na.rm=TRUE)\n", "primary_school_age_pct <- (primary_school_age / population_total) * 100.0\n", "names(primary_school_age_pct)[1] <- 'primary_school_age_pct'\n", "\n", "# One person households\n", "one_person_households_fields<- c(\n", " 'T5_1OP_H' # One person households\n", ")\n", "one_person_households_data <- census_data[, one_person_households_fields, drop = FALSE]\n", "one_person_households <- rowSums(one_person_households_data, na.rm=TRUE)\n", "one_person_households_pct <- (one_person_households / households_total) * 100.0\n", "names(one_person_households_pct)[1] <- 'one_person_households_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "social_network_domain_pct <- cbind(not_volunteers_pct,\n", " primary_school_age_pct,\n", " one_person_households_pct)\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(social_network_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Housing Characteristics domain" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 5
no_central_heating_pctprivate_water_supply_pctyear_built_pctmobile_home_pctunoccupied_dwellings_pct
<dbl><dbl><dbl><dbl><dbl>
10.000000087.59124117.5182481.459854010.218978
21.694915376.27118618.6440680.0000000 3.389831
30.8403361 1.680672 5.8823530.0000000 3.361345
40.632911430.37974718.3544300.6329114 5.063291
52.197802271.42857124.1758241.0989011 7.692308
60.840336121.84873928.5714290.8403361 7.563025
\n" ], "text/latex": [ "A data.frame: 6 × 5\n", "\\begin{tabular}{r|lllll}\n", " & no\\_central\\_heating\\_pct & private\\_water\\_supply\\_pct & year\\_built\\_pct & mobile\\_home\\_pct & unoccupied\\_dwellings\\_pct\\\\\n", " & & & & & \\\\\n", "\\hline\n", "\t1 & 0.0000000 & 87.591241 & 17.518248 & 1.4598540 & 10.218978\\\\\n", "\t2 & 1.6949153 & 76.271186 & 18.644068 & 0.0000000 & 3.389831\\\\\n", "\t3 & 0.8403361 & 1.680672 & 5.882353 & 0.0000000 & 3.361345\\\\\n", "\t4 & 0.6329114 & 30.379747 & 18.354430 & 0.6329114 & 5.063291\\\\\n", "\t5 & 2.1978022 & 71.428571 & 24.175824 & 1.0989011 & 7.692308\\\\\n", "\t6 & 0.8403361 & 21.848739 & 28.571429 & 0.8403361 & 7.563025\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 5\n", "\n", "| | no_central_heating_pct <dbl> | private_water_supply_pct <dbl> | year_built_pct <dbl> | mobile_home_pct <dbl> | unoccupied_dwellings_pct <dbl> |\n", "|---|---|---|---|---|---|\n", "| 1 | 0.0000000 | 87.591241 | 17.518248 | 1.4598540 | 10.218978 |\n", "| 2 | 1.6949153 | 76.271186 | 18.644068 | 0.0000000 | 3.389831 |\n", "| 3 | 0.8403361 | 1.680672 | 5.882353 | 0.0000000 | 3.361345 |\n", "| 4 | 0.6329114 | 30.379747 | 18.354430 | 0.6329114 | 5.063291 |\n", "| 5 | 2.1978022 | 71.428571 | 24.175824 | 1.0989011 | 7.692308 |\n", "| 6 | 0.8403361 | 21.848739 | 28.571429 | 0.8403361 | 7.563025 |\n", "\n" ], "text/plain": [ " no_central_heating_pct private_water_supply_pct year_built_pct\n", "1 0.0000000 87.591241 17.518248 \n", "2 1.6949153 76.271186 18.644068 \n", "3 0.8403361 1.680672 5.882353 \n", "4 0.6329114 30.379747 18.354430 \n", "5 2.1978022 71.428571 24.175824 \n", "6 0.8403361 21.848739 28.571429 \n", " mobile_home_pct unoccupied_dwellings_pct\n", "1 1.4598540 10.218978 \n", "2 0.0000000 3.389831 \n", "3 0.0000000 3.361345 \n", "4 0.6329114 5.063291 \n", "5 1.0989011 7.692308 \n", "6 0.8403361 7.563025 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "### Domain: Housing Characteristics ####\n", "\n", "# Indicator: Permanent private households by central heating\n", "no_central_heating_fields <- c(\n", " 'T6_5_NCH' # No central heating\n", ")\n", "no_central_heating_data <- census_data[, no_central_heating_fields, drop = FALSE]\n", "no_central_heating <- rowSums(no_central_heating_data, na.rm=TRUE)\n", "no_central_heating_pct <- (no_central_heating / households_total) * 100.0\n", "names(no_central_heating_pct)[1] <- 'no_central_heating_pct'\n", "\n", "# Indicator: Permanent private households by water supply \n", "private_water_supply_fields <- c(\n", " 'T6_6_GSP', # Group scheme with private source\n", " 'T6_6_OP' # Other private source\n", ")\n", "private_water_supply_data <- census_data[, private_water_supply_fields, drop = FALSE]\n", "private_water_supply <- rowSums(private_water_supply_data, na.rm=TRUE)\n", "private_water_supply_pct <- (private_water_supply / households_total) * 100.0\n", "names(private_water_supply_pct)[1] <- 'private_water_supply_pct'\n", "\n", "# Indicator: Permanent private households by year built\n", "year_built_fields <- c(\n", " 'T6_2_PRE19H', # Pre 1919 (No. of households)\n", " 'T6_2_19_45H' # 1919 - 1945 (No. of households)\n", ")\n", "year_built_data <- census_data[, year_built_fields, drop = FALSE]\n", "year_built <- rowSums(year_built_data, na.rm=TRUE)\n", "year_built_pct <- (year_built / households_total) * 100.0\n", "names(year_built_pct)[1] <- 'year_built_pct'\n", "\n", "# Indicator: Permanent private households by year built\n", "year_built_fields <- c(\n", " 'T6_2_PRE19H', # Pre 1919 (No. of households)\n", " 'T6_2_19_45H' # 1919 - 1945 (No. of households)\n", ")\n", "year_built_data <- census_data[, year_built_fields, drop = FALSE]\n", "year_built <- rowSums(year_built_data, na.rm=TRUE)\n", "year_built_pct <- (year_built / households_total) * 100.0\n", "names(year_built_pct)[1] <- 'year_built_pct'\n", "\n", "# Indicator: Private households by type of accommodation \n", "mobile_home_fields <- c(\n", " 'T6_1_CM_H' # Caravan/Mobile home (No. of households)\n", ")\n", "mobile_home_data <- census_data[, mobile_home_fields, drop = FALSE]\n", "mobile_home <- rowSums(mobile_home_data, na.rm=TRUE)\n", "mobile_home_pct <- (mobile_home / households_total) * 100.0\n", "names(mobile_home_pct)[1] <- 'mobile_home_pct'\n", "\n", "# Indicator: Occupancy status of permanent dwellings on Census night \n", "unoccupied_dwellings_fields <- c(\n", " 'T6_8_TA', # Temporarily absent\n", " 'T6_8_UHH', # Unoccupied holiday homes\n", " 'T6_8_OVD' # Other vacant dwellings\n", ")\n", "unoccupied_dwellings_data <- census_data[, unoccupied_dwellings_fields, drop = FALSE]\n", "unoccupied_dwellings <- rowSums(unoccupied_dwellings_data, na.rm=TRUE)\n", "unoccupied_dwellings_pct <- (unoccupied_dwellings / households_total) * 100.0\n", "names(unoccupied_dwellings_pct)[1] <- 'unoccupied_dwellings_pct'\n", "\n", "# Combine all these indicators into an array for this domain\n", "housing_characteristics_domain_pct <- cbind(no_central_heating_pct,\n", " private_water_supply_pct,\n", " year_built_pct,\n", " mobile_home_pct,\n", " unoccupied_dwellings_pct\n", " )\n", "\n", "# Print the first six rows of the data to visually check it looks OK\n", "head(housing_characteristics_domain_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Combine all data into one table" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 26
GUIDearly_childhood_pctage_middle_to_oldest_old_pctpoor_health_pctdisability_pctone_parent_households_pctthree_or_more_children_households_pctlow_skilled_employment_pctfarmers_pctunemployment_pctrented_pctjourney_time_pctnot_volunteers_pctprimary_school_age_pctone_person_households_pctno_central_heating_pctprivate_water_supply_pctyear_built_pctmobile_home_pctunoccupied_dwellings_pct
<chr><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl><dbl>
14c07d11e-11d3-851d-e053-ca3ca8c0ca7f6.443914 4.5346061.67064419.09308 6.56934316.78832123.6276814.081146 8.830549 5.2505977.15990587.3508414.0811515.328470.000000087.59124117.5182481.459854010.218978
24c07d11e-123a-851d-e053-ca3ca8c0ca7f6.08695711.0144932.02898625.50725 8.47457612.71186417.10145 9.56521711.884058 6.0869576.37681279.7101411.3043514.406781.694915376.27118618.6440680.0000000 3.389831
34c07d11e-14b1-851d-e053-ca3ca8c0ca7f5.621302 3.5502963.55029623.6686414.285714 9.24369715.97633 0.59171613.60946724.8520715.62130283.7278113.0177519.327730.8403361 1.680672 5.8823530.0000000 3.361345
4bf640964-28f3-4ccf-a610-04685d80ea2e8.883827 8.8838272.27790420.95672 7.594937 7.59493712.98405 4.10022812.300683 9.7949893.64464782.2323512.9840522.151900.632911430.37974718.3544300.6329114 5.063291
54c07d11d-f709-851d-e053-ca3ca8c0ca7f6.274510 5.0980391.96078416.47059 8.79120913.18681316.8627512.94117611.764706 3.5294126.27451083.9215713.3333321.978022.197802271.42857124.1758241.0989011 7.692308
64c07d11e-1237-851d-e053-ca3ca8c0ca7f7.267442 8.1395352.61627927.32558 8.40336114.28571427.0348812.20930215.697674 9.8837218.13953581.1046512.7907016.806720.840336121.84873928.5714290.8403361 7.563025
\n" ], "text/latex": [ "A data.frame: 6 × 26\n", "\\begin{tabular}{r|lllllllllllllllllllll}\n", " & GUID & early\\_childhood\\_pct & age\\_middle\\_to\\_oldest\\_old\\_pct & poor\\_health\\_pct & disability\\_pct & one\\_parent\\_households\\_pct & three\\_or\\_more\\_children\\_households\\_pct & low\\_skilled\\_employment\\_pct & farmers\\_pct & unemployment\\_pct & ⋯ & rented\\_pct & journey\\_time\\_pct & not\\_volunteers\\_pct & primary\\_school\\_age\\_pct & one\\_person\\_households\\_pct & no\\_central\\_heating\\_pct & private\\_water\\_supply\\_pct & year\\_built\\_pct & mobile\\_home\\_pct & unoccupied\\_dwellings\\_pct\\\\\n", " & & & & & & & & & & & ⋯ & & & & & & & & & & \\\\\n", "\\hline\n", "\t1 & 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f & 6.443914 & 4.534606 & 1.670644 & 19.09308 & 6.569343 & 16.788321 & 23.62768 & 14.081146 & 8.830549 & ⋯ & 5.250597 & 7.159905 & 87.35084 & 14.08115 & 15.32847 & 0.0000000 & 87.591241 & 17.518248 & 1.4598540 & 10.218978\\\\\n", "\t2 & 4c07d11e-123a-851d-e053-ca3ca8c0ca7f & 6.086957 & 11.014493 & 2.028986 & 25.50725 & 8.474576 & 12.711864 & 17.10145 & 9.565217 & 11.884058 & ⋯ & 6.086957 & 6.376812 & 79.71014 & 11.30435 & 14.40678 & 1.6949153 & 76.271186 & 18.644068 & 0.0000000 & 3.389831\\\\\n", "\t3 & 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f & 5.621302 & 3.550296 & 3.550296 & 23.66864 & 14.285714 & 9.243697 & 15.97633 & 0.591716 & 13.609467 & ⋯ & 24.852071 & 5.621302 & 83.72781 & 13.01775 & 19.32773 & 0.8403361 & 1.680672 & 5.882353 & 0.0000000 & 3.361345\\\\\n", "\t4 & bf640964-28f3-4ccf-a610-04685d80ea2e & 8.883827 & 8.883827 & 2.277904 & 20.95672 & 7.594937 & 7.594937 & 12.98405 & 4.100228 & 12.300683 & ⋯ & 9.794989 & 3.644647 & 82.23235 & 12.98405 & 22.15190 & 0.6329114 & 30.379747 & 18.354430 & 0.6329114 & 5.063291\\\\\n", "\t5 & 4c07d11d-f709-851d-e053-ca3ca8c0ca7f & 6.274510 & 5.098039 & 1.960784 & 16.47059 & 8.791209 & 13.186813 & 16.86275 & 12.941176 & 11.764706 & ⋯ & 3.529412 & 6.274510 & 83.92157 & 13.33333 & 21.97802 & 2.1978022 & 71.428571 & 24.175824 & 1.0989011 & 7.692308\\\\\n", "\t6 & 4c07d11e-1237-851d-e053-ca3ca8c0ca7f & 7.267442 & 8.139535 & 2.616279 & 27.32558 & 8.403361 & 14.285714 & 27.03488 & 12.209302 & 15.697674 & ⋯ & 9.883721 & 8.139535 & 81.10465 & 12.79070 & 16.80672 & 0.8403361 & 21.848739 & 28.571429 & 0.8403361 & 7.563025\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 26\n", "\n", "| | GUID <chr> | early_childhood_pct <dbl> | age_middle_to_oldest_old_pct <dbl> | poor_health_pct <dbl> | disability_pct <dbl> | one_parent_households_pct <dbl> | three_or_more_children_households_pct <dbl> | low_skilled_employment_pct <dbl> | farmers_pct <dbl> | unemployment_pct <dbl> | ⋯ ⋯ | rented_pct <dbl> | journey_time_pct <dbl> | not_volunteers_pct <dbl> | primary_school_age_pct <dbl> | one_person_households_pct <dbl> | no_central_heating_pct <dbl> | private_water_supply_pct <dbl> | year_built_pct <dbl> | mobile_home_pct <dbl> | unoccupied_dwellings_pct <dbl> |\n", "|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n", "| 1 | 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f | 6.443914 | 4.534606 | 1.670644 | 19.09308 | 6.569343 | 16.788321 | 23.62768 | 14.081146 | 8.830549 | ⋯ | 5.250597 | 7.159905 | 87.35084 | 14.08115 | 15.32847 | 0.0000000 | 87.591241 | 17.518248 | 1.4598540 | 10.218978 |\n", "| 2 | 4c07d11e-123a-851d-e053-ca3ca8c0ca7f | 6.086957 | 11.014493 | 2.028986 | 25.50725 | 8.474576 | 12.711864 | 17.10145 | 9.565217 | 11.884058 | ⋯ | 6.086957 | 6.376812 | 79.71014 | 11.30435 | 14.40678 | 1.6949153 | 76.271186 | 18.644068 | 0.0000000 | 3.389831 |\n", "| 3 | 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f | 5.621302 | 3.550296 | 3.550296 | 23.66864 | 14.285714 | 9.243697 | 15.97633 | 0.591716 | 13.609467 | ⋯ | 24.852071 | 5.621302 | 83.72781 | 13.01775 | 19.32773 | 0.8403361 | 1.680672 | 5.882353 | 0.0000000 | 3.361345 |\n", "| 4 | bf640964-28f3-4ccf-a610-04685d80ea2e | 8.883827 | 8.883827 | 2.277904 | 20.95672 | 7.594937 | 7.594937 | 12.98405 | 4.100228 | 12.300683 | ⋯ | 9.794989 | 3.644647 | 82.23235 | 12.98405 | 22.15190 | 0.6329114 | 30.379747 | 18.354430 | 0.6329114 | 5.063291 |\n", "| 5 | 4c07d11d-f709-851d-e053-ca3ca8c0ca7f | 6.274510 | 5.098039 | 1.960784 | 16.47059 | 8.791209 | 13.186813 | 16.86275 | 12.941176 | 11.764706 | ⋯ | 3.529412 | 6.274510 | 83.92157 | 13.33333 | 21.97802 | 2.1978022 | 71.428571 | 24.175824 | 1.0989011 | 7.692308 |\n", "| 6 | 4c07d11e-1237-851d-e053-ca3ca8c0ca7f | 7.267442 | 8.139535 | 2.616279 | 27.32558 | 8.403361 | 14.285714 | 27.03488 | 12.209302 | 15.697674 | ⋯ | 9.883721 | 8.139535 | 81.10465 | 12.79070 | 16.80672 | 0.8403361 | 21.848739 | 28.571429 | 0.8403361 | 7.563025 |\n", "\n" ], "text/plain": [ " GUID early_childhood_pct\n", "1 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f 6.443914 \n", "2 4c07d11e-123a-851d-e053-ca3ca8c0ca7f 6.086957 \n", "3 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f 5.621302 \n", "4 bf640964-28f3-4ccf-a610-04685d80ea2e 8.883827 \n", "5 4c07d11d-f709-851d-e053-ca3ca8c0ca7f 6.274510 \n", "6 4c07d11e-1237-851d-e053-ca3ca8c0ca7f 7.267442 \n", " age_middle_to_oldest_old_pct poor_health_pct disability_pct\n", "1 4.534606 1.670644 19.09308 \n", "2 11.014493 2.028986 25.50725 \n", "3 3.550296 3.550296 23.66864 \n", "4 8.883827 2.277904 20.95672 \n", "5 5.098039 1.960784 16.47059 \n", "6 8.139535 2.616279 27.32558 \n", " one_parent_households_pct three_or_more_children_households_pct\n", "1 6.569343 16.788321 \n", "2 8.474576 12.711864 \n", "3 14.285714 9.243697 \n", "4 7.594937 7.594937 \n", "5 8.791209 13.186813 \n", "6 8.403361 14.285714 \n", " low_skilled_employment_pct farmers_pct unemployment_pct ⋯ rented_pct\n", "1 23.62768 14.081146 8.830549 ⋯ 5.250597 \n", "2 17.10145 9.565217 11.884058 ⋯ 6.086957 \n", "3 15.97633 0.591716 13.609467 ⋯ 24.852071 \n", "4 12.98405 4.100228 12.300683 ⋯ 9.794989 \n", "5 16.86275 12.941176 11.764706 ⋯ 3.529412 \n", "6 27.03488 12.209302 15.697674 ⋯ 9.883721 \n", " journey_time_pct not_volunteers_pct primary_school_age_pct\n", "1 7.159905 87.35084 14.08115 \n", "2 6.376812 79.71014 11.30435 \n", "3 5.621302 83.72781 13.01775 \n", "4 3.644647 82.23235 12.98405 \n", "5 6.274510 83.92157 13.33333 \n", "6 8.139535 81.10465 12.79070 \n", " one_person_households_pct no_central_heating_pct private_water_supply_pct\n", "1 15.32847 0.0000000 87.591241 \n", "2 14.40678 1.6949153 76.271186 \n", "3 19.32773 0.8403361 1.680672 \n", "4 22.15190 0.6329114 30.379747 \n", "5 21.97802 2.1978022 71.428571 \n", "6 16.80672 0.8403361 21.848739 \n", " year_built_pct mobile_home_pct unoccupied_dwellings_pct\n", "1 17.518248 1.4598540 10.218978 \n", "2 18.644068 0.0000000 3.389831 \n", "3 5.882353 0.0000000 3.361345 \n", "4 18.354430 0.6329114 5.063291 \n", "5 24.175824 1.0989011 7.692308 \n", "6 28.571429 0.8403361 7.563025 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Combine all data into one table\n", "indicator_domains_pct <- cbind(census_area_id,\n", " age_domain_pct,\n", " health_domain_pct,\n", " income_domain_pct,\n", " info_domain_pct,\n", " local_knowledge_domain_pct,\n", " mobility_domain_pct,\n", " tenure_domain_pct,\n", " physical_access_domain_pct,\n", " social_network_domain_pct,\n", " housing_characteristics_domain_pct)\n", "head(indicator_domains_pct)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Calculate Z-Score\n", "The raw data is not suitable for use within the vulnerabiltiy assessment. It needs to be standardised. Therefore, the data is converted to z-scores. Z-scores are:\n", "\n", ">\"A statistical measurement of a score's relationship to the mean (average value) in a group of scores. A Z-score of 0 means the score is the same as the mean (average value). A Z-score can be positive or negative, indicating whether it is above or below the mean and by how many standard deviations. Z-score standardisation represents the deviation of a raw score from its mean in standard deviation units.\" (Kazmierczak et al., 2015)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Calculate the Z-score" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\t\n", "\t\n", "\n", "\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\t\n", "\n", "
A data.frame: 6 × 26
GUIDearly_childhoodage_middle_to_oldest_oldpoor_healthdisabilityone_parent_householdsthree_or_more_children_householdslow_skilled_employmentfarmersunemploymentrentedjourney_timenot_volunteersprimary_school_ageone_person_householdsno_central_heatingprivate_water_supplyyear_builtmobile_homeunoccupied_dwellings
<chr><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]><dbl[,1]>
14c07d11e-11d3-851d-e053-ca3ca8c0ca7f-0.1079508-0.4448091-0.0867229-0.4589362-0.6992867 0.7971503 0.3821265 1.8818244-0.83703083-0.9475582 0.6458280 0.2721853 0.53543614-0.7988385-0.7784105 2.8290832 0.1247138 0.9507964-0.2685905
24c07d11e-123a-851d-e053-ca3ca8c0ca7f-0.2315741 0.7875206 0.1669895 0.5523710-0.4125867 0.1677345-0.3005233 1.0930868-0.26121797-0.9117719 0.3856925-1.2744132-0.09998755-0.8885092 0.3283476 2.3937964 0.1865261-0.1877926-0.5759916
34c07d11e-14b1-851d-e053-ca3ca8c0ca7f-0.3928420-0.6320030 1.2441066 0.2624819 0.4618750-0.3677598-0.4182116-0.4741963 0.06414964-0.1088473 0.1347198-0.4611731 0.29209620-0.4097515-0.2296817-0.4744110-0.5141473-0.1877926-0.5772738
4bf640964-28f3-4ccf-a610-04685d80ea2e 0.7370521 0.3823155 0.3432288-0.1651002-0.5449551-0.6223328-0.7312063 0.1385892-0.18265319-0.7531121-0.5219048-0.7638791 0.28438525-0.1349893-0.3651274 0.6291462 0.1706238 0.3058362-0.5006639
54c07d11d-f709-851d-e053-ca3ca8c0ca7f-0.1666197-0.3376567 0.1187018-0.8724183-0.3649398 0.2410678-0.3254920 1.6827210-0.28372469-1.0212046 0.3517089-0.4219533 0.36431183-0.1519057 0.6567264 2.2075847 0.4902435 0.6692771-0.3823238
64c07d11e-1237-851d-e053-ca3ca8c0ca7f 0.1772575 0.2407678 0.5828047 0.8390637-0.4233032 0.4107411 0.7385225 1.5548942 0.45793149-0.7493154 0.9712513-0.9921427 0.24013874-0.6550195-0.2296817 0.3011058 0.7315812 0.4676137-0.3881432
\n" ], "text/latex": [ "A data.frame: 6 × 26\n", "\\begin{tabular}{r|lllllllllllllllllllll}\n", " & GUID & early\\_childhood & age\\_middle\\_to\\_oldest\\_old & poor\\_health & disability & one\\_parent\\_households & three\\_or\\_more\\_children\\_households & low\\_skilled\\_employment & farmers & unemployment & ⋯ & rented & journey\\_time & not\\_volunteers & primary\\_school\\_age & one\\_person\\_households & no\\_central\\_heating & private\\_water\\_supply & year\\_built & mobile\\_home & unoccupied\\_dwellings\\\\\n", " & & & & & & & & & & & ⋯ & & & & & & & & & & \\\\\n", "\\hline\n", "\t1 & 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f & -0.1079508 & -0.4448091 & -0.0867229 & -0.4589362 & -0.6992867 & 0.7971503 & 0.3821265 & 1.8818244 & -0.83703083 & ⋯ & -0.9475582 & 0.6458280 & 0.2721853 & 0.53543614 & -0.7988385 & -0.7784105 & 2.8290832 & 0.1247138 & 0.9507964 & -0.2685905\\\\\n", "\t2 & 4c07d11e-123a-851d-e053-ca3ca8c0ca7f & -0.2315741 & 0.7875206 & 0.1669895 & 0.5523710 & -0.4125867 & 0.1677345 & -0.3005233 & 1.0930868 & -0.26121797 & ⋯ & -0.9117719 & 0.3856925 & -1.2744132 & -0.09998755 & -0.8885092 & 0.3283476 & 2.3937964 & 0.1865261 & -0.1877926 & -0.5759916\\\\\n", "\t3 & 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f & -0.3928420 & -0.6320030 & 1.2441066 & 0.2624819 & 0.4618750 & -0.3677598 & -0.4182116 & -0.4741963 & 0.06414964 & ⋯ & -0.1088473 & 0.1347198 & -0.4611731 & 0.29209620 & -0.4097515 & -0.2296817 & -0.4744110 & -0.5141473 & -0.1877926 & -0.5772738\\\\\n", "\t4 & bf640964-28f3-4ccf-a610-04685d80ea2e & 0.7370521 & 0.3823155 & 0.3432288 & -0.1651002 & -0.5449551 & -0.6223328 & -0.7312063 & 0.1385892 & -0.18265319 & ⋯ & -0.7531121 & -0.5219048 & -0.7638791 & 0.28438525 & -0.1349893 & -0.3651274 & 0.6291462 & 0.1706238 & 0.3058362 & -0.5006639\\\\\n", "\t5 & 4c07d11d-f709-851d-e053-ca3ca8c0ca7f & -0.1666197 & -0.3376567 & 0.1187018 & -0.8724183 & -0.3649398 & 0.2410678 & -0.3254920 & 1.6827210 & -0.28372469 & ⋯ & -1.0212046 & 0.3517089 & -0.4219533 & 0.36431183 & -0.1519057 & 0.6567264 & 2.2075847 & 0.4902435 & 0.6692771 & -0.3823238\\\\\n", "\t6 & 4c07d11e-1237-851d-e053-ca3ca8c0ca7f & 0.1772575 & 0.2407678 & 0.5828047 & 0.8390637 & -0.4233032 & 0.4107411 & 0.7385225 & 1.5548942 & 0.45793149 & ⋯ & -0.7493154 & 0.9712513 & -0.9921427 & 0.24013874 & -0.6550195 & -0.2296817 & 0.3011058 & 0.7315812 & 0.4676137 & -0.3881432\\\\\n", "\\end{tabular}\n" ], "text/markdown": [ "\n", "A data.frame: 6 × 26\n", "\n", "| | GUID <chr> | early_childhood <dbl[,1]> | age_middle_to_oldest_old <dbl[,1]> | poor_health <dbl[,1]> | disability <dbl[,1]> | one_parent_households <dbl[,1]> | three_or_more_children_households <dbl[,1]> | low_skilled_employment <dbl[,1]> | farmers <dbl[,1]> | unemployment <dbl[,1]> | ⋯ ⋯ | rented <dbl[,1]> | journey_time <dbl[,1]> | not_volunteers <dbl[,1]> | primary_school_age <dbl[,1]> | one_person_households <dbl[,1]> | no_central_heating <dbl[,1]> | private_water_supply <dbl[,1]> | year_built <dbl[,1]> | mobile_home <dbl[,1]> | unoccupied_dwellings <dbl[,1]> |\n", "|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n", "| 1 | 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f | -0.1079508 | -0.4448091 | -0.0867229 | -0.4589362 | -0.6992867 | 0.7971503 | 0.3821265 | 1.8818244 | -0.83703083 | ⋯ | -0.9475582 | 0.6458280 | 0.2721853 | 0.53543614 | -0.7988385 | -0.7784105 | 2.8290832 | 0.1247138 | 0.9507964 | -0.2685905 |\n", "| 2 | 4c07d11e-123a-851d-e053-ca3ca8c0ca7f | -0.2315741 | 0.7875206 | 0.1669895 | 0.5523710 | -0.4125867 | 0.1677345 | -0.3005233 | 1.0930868 | -0.26121797 | ⋯ | -0.9117719 | 0.3856925 | -1.2744132 | -0.09998755 | -0.8885092 | 0.3283476 | 2.3937964 | 0.1865261 | -0.1877926 | -0.5759916 |\n", "| 3 | 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f | -0.3928420 | -0.6320030 | 1.2441066 | 0.2624819 | 0.4618750 | -0.3677598 | -0.4182116 | -0.4741963 | 0.06414964 | ⋯ | -0.1088473 | 0.1347198 | -0.4611731 | 0.29209620 | -0.4097515 | -0.2296817 | -0.4744110 | -0.5141473 | -0.1877926 | -0.5772738 |\n", "| 4 | bf640964-28f3-4ccf-a610-04685d80ea2e | 0.7370521 | 0.3823155 | 0.3432288 | -0.1651002 | -0.5449551 | -0.6223328 | -0.7312063 | 0.1385892 | -0.18265319 | ⋯ | -0.7531121 | -0.5219048 | -0.7638791 | 0.28438525 | -0.1349893 | -0.3651274 | 0.6291462 | 0.1706238 | 0.3058362 | -0.5006639 |\n", "| 5 | 4c07d11d-f709-851d-e053-ca3ca8c0ca7f | -0.1666197 | -0.3376567 | 0.1187018 | -0.8724183 | -0.3649398 | 0.2410678 | -0.3254920 | 1.6827210 | -0.28372469 | ⋯ | -1.0212046 | 0.3517089 | -0.4219533 | 0.36431183 | -0.1519057 | 0.6567264 | 2.2075847 | 0.4902435 | 0.6692771 | -0.3823238 |\n", "| 6 | 4c07d11e-1237-851d-e053-ca3ca8c0ca7f | 0.1772575 | 0.2407678 | 0.5828047 | 0.8390637 | -0.4233032 | 0.4107411 | 0.7385225 | 1.5548942 | 0.45793149 | ⋯ | -0.7493154 | 0.9712513 | -0.9921427 | 0.24013874 | -0.6550195 | -0.2296817 | 0.3011058 | 0.7315812 | 0.4676137 | -0.3881432 |\n", "\n" ], "text/plain": [ " GUID early_childhood age_middle_to_oldest_old\n", "1 4c07d11e-11d3-851d-e053-ca3ca8c0ca7f -0.1079508 -0.4448091 \n", "2 4c07d11e-123a-851d-e053-ca3ca8c0ca7f -0.2315741 0.7875206 \n", "3 4c07d11e-14b1-851d-e053-ca3ca8c0ca7f -0.3928420 -0.6320030 \n", "4 bf640964-28f3-4ccf-a610-04685d80ea2e 0.7370521 0.3823155 \n", "5 4c07d11d-f709-851d-e053-ca3ca8c0ca7f -0.1666197 -0.3376567 \n", "6 4c07d11e-1237-851d-e053-ca3ca8c0ca7f 0.1772575 0.2407678 \n", " poor_health disability one_parent_households\n", "1 -0.0867229 -0.4589362 -0.6992867 \n", "2 0.1669895 0.5523710 -0.4125867 \n", "3 1.2441066 0.2624819 0.4618750 \n", "4 0.3432288 -0.1651002 -0.5449551 \n", "5 0.1187018 -0.8724183 -0.3649398 \n", "6 0.5828047 0.8390637 -0.4233032 \n", " three_or_more_children_households low_skilled_employment farmers \n", "1 0.7971503 0.3821265 1.8818244\n", "2 0.1677345 -0.3005233 1.0930868\n", "3 -0.3677598 -0.4182116 -0.4741963\n", "4 -0.6223328 -0.7312063 0.1385892\n", "5 0.2410678 -0.3254920 1.6827210\n", "6 0.4107411 0.7385225 1.5548942\n", " unemployment ⋯ rented journey_time not_volunteers primary_school_age\n", "1 -0.83703083 ⋯ -0.9475582 0.6458280 0.2721853 0.53543614 \n", "2 -0.26121797 ⋯ -0.9117719 0.3856925 -1.2744132 -0.09998755 \n", "3 0.06414964 ⋯ -0.1088473 0.1347198 -0.4611731 0.29209620 \n", "4 -0.18265319 ⋯ -0.7531121 -0.5219048 -0.7638791 0.28438525 \n", "5 -0.28372469 ⋯ -1.0212046 0.3517089 -0.4219533 0.36431183 \n", "6 0.45793149 ⋯ -0.7493154 0.9712513 -0.9921427 0.24013874 \n", " one_person_households no_central_heating private_water_supply year_built\n", "1 -0.7988385 -0.7784105 2.8290832 0.1247138\n", "2 -0.8885092 0.3283476 2.3937964 0.1865261\n", "3 -0.4097515 -0.2296817 -0.4744110 -0.5141473\n", "4 -0.1349893 -0.3651274 0.6291462 0.1706238\n", "5 -0.1519057 0.6567264 2.2075847 0.4902435\n", "6 -0.6550195 -0.2296817 0.3011058 0.7315812\n", " mobile_home unoccupied_dwellings\n", "1 0.9507964 -0.2685905 \n", "2 -0.1877926 -0.5759916 \n", "3 -0.1877926 -0.5772738 \n", "4 0.3058362 -0.5006639 \n", "5 0.6692771 -0.3823238 \n", "6 0.4676137 -0.3881432 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Copy the data\n", "indicator_z_scores <- indicator_domains_pct\n", "\n", "# Get the number of columns in the data\n", "num_cols = ncol(indicator_z_scores)\n", "\n", "# Calculate the z scores for each of the relevant columns - starting at the 2nd column\n", "for(col in names(indicator_z_scores)[2:num_cols]) {\n", " # rename column (remove the '_pct' in the name)\n", " new_col_name <- gsub(\"_pct\", \"\", col)\n", " indicator_z_scores[new_col_name] = scale(indicator_z_scores[col])\n", "}\n", "\n", "# Remove the original data to leave only the area identifier and the z scores\n", "indicator_z_scores <- indicator_z_scores[-c(2:num_cols)]\n", "\n", "head(indicator_z_scores)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Output the Z-score data" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "# Output the z-score data as a csv file\n", "output_file <- file.path(pipeline_dir, \"censusDataZ.csv\")\n", "write.csv(indicator_z_scores, output_file, row.names = FALSE)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**END**" ] } ], "metadata": { "kernelspec": { "display_name": "R", "language": "R", "name": "ir" }, "language_info": { "codemirror_mode": "r", "file_extension": ".r", "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", "version": "4.3.3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }