Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: IMD
Type: Package
Title: Index of Multiple Deprivation Data for the UK
Version: 2.0.0
Version: 2.0.0.9000
Authors@R: c(
person(given = c("Matthew", "Gwynfryn"),
family = "Thomas",
Expand Down Expand Up @@ -30,7 +30,7 @@ URL: https://github.com/humaniverse/IMD
BugReports: https://github.com/humaniverse/IMD/issues
Encoding: UTF-8
LazyData: true
LazyDataCompression:xz
LazyDataCompression: xz
RoxygenNote: 7.3.3
Imports:
rlang,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# IMD (development version)

- Added subdomain data for England's 2004, 2007, 2010 and 2015 Indices of Deprivation

# IMD 2.0.0

## Breaking changes
Expand Down
138 changes: 138 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,36 @@ NULL
#' @source \url{https://www.gov.uk/}
"imd2015_england_lsoa11"

#' Index of Multiple Deprivation (2015) subdomains for LSOAs in England
#'
#' A data set containing subdomain scores, ranks and deciles for LSOAs in England.
#'
#' @format A data frame of class "tbl" with 32,844 rows and 19 variables:
#' \describe{
#' \item{lsoa11_code}{LSOA (2011) code}
#' \item{adult_skills_sub_domain_score}{Adult Skills score}
#' \item{children_and_young_people_sub_domain_score}{Children and Young People score}
#' \item{adult_skills_sub_domain_rank}{Adult Skills rank}
#' \item{children_and_young_people_sub_domain_rank}{Children and Young People rank}
#' \item{adult_skills_sub_domain_decile}{Adult Skills decile}
#' \item{children_and_young_people_sub_domain_decile}{Children and Young People decile}
#' \item{wider_barriers_sub_domain_score}{Wider Barriers score}
#' \item{geographical_barriers_sub_domain_score}{Geographical Barriers score}
#' \item{wider_barriers_sub_domain_rank}{Wider Barriers rank}
#' \item{geographical_barriers_sub_domain_rank}{Geographical Barriers rank}
#' \item{wider_barriers_sub_domain_decile}{Wider Barriers decile}
#' \item{geographical_barriers_sub_domain_decile}{Geographical Barriers decile}
#' \item{indoors_sub_domain_score}{Indoors score}
#' \item{outdoors_sub_domain_score}{Outdoors score}
#' \item{indoors_sub_domain_rank}{Indoors rank}
#' \item{outdoors_sub_domain_rank}{Outdoors ranks}
#' \item{indoors_sub_domain_decile}{Indoors decile}
#' \item{outdoors_sub_domain_decile}{Outdoors decile}
#' ...
#' }
#' @source \url{https://www.gov.uk/}
"imd2015_england_lsoa01_subdomains"

#' Index of Multiple Deprivation (2015) for Local Authorities in England
#'
#' A data set containing IMD proportions and extents for Local Authorites
Expand Down Expand Up @@ -1555,6 +1585,36 @@ NULL
#' @source \url{https://www.gov.uk/}
"imd2010_england_lsoa01"

#' Index of Multiple Deprivation (2010) subdomains for LSOAs in England
#'
#' A data set containing subdomain scores, ranks and deciles for LSOAs in England.
#'
#' @format A data frame of class "tbl" with 32,482 rows and 19 variables:
#' \describe{
#' \item{lsoa01_code}{LSOA (2001) code}
#' \item{skills_sub_domain_score}{Skills score}
#' \item{children_young_people_sub_domain_score}{Children and Young People score}
#' \item{skills_sub_domain_rank}{Skills rank}
#' \item{children_young_people_sub_domain_rank}{Children and Young People rank}
#' \item{skills_sub_domain_decile}{Skills decile}
#' \item{children_young_people_sub_domain_decile}{Children and Young People decile}
#' \item{wider_barriers_sub_domain_score}{Wider Barriers score}
#' \item{geographical_barriers_sub_domain_score}{Geographical Barriers score}
#' \item{wider_barriers_sub_domain_rank}{Wider Barriers rank}
#' \item{geographical_barriers_sub_domain_rank}{Geographical Barriers rank}
#' \item{wider_barriers_sub_domain_decile}{Wider Barriers decile}
#' \item{geographical_barriers_sub_domain_decile}{Geographical Barriers decile}
#' \item{indoors_sub_domain_score}{Indoors score}
#' \item{outdoors_sub_domain_score}{Outdoors score}
#' \item{indoors_sub_domain_rank}{Indoors rank}
#' \item{outdoors_sub_domain_rank}{Outdoors ranks}
#' \item{indoors_sub_domain_decile}{Indoors decile}
#' \item{outdoors_sub_domain_decile}{Outdoors decile}
#' ...
#' }
#' @source \url{https://www.gov.uk/}
"imd2010_england_lsoa01_subdomains"

#' Index of Multiple Deprivation (2010) for Local Authorities in England
#'
#' A data set containing IMD scores, proportions and extents for Local
Expand Down Expand Up @@ -1650,6 +1710,45 @@ NULL
#' @source \url{https://www.gov.uk/}
"imd2007_england_lsoa01"

#' Index of Multiple Deprivation (2007) subdomains for LSOAs in England
#'
#' A data set containing subdomain scores, ranks and deciles for LSOAs in England.
#'
#' @format A data frame of class "tbl" with 32,482 rows and 28 variables:
#' \describe{
#' \item{lsoa01_code}{LSOA (2001) code}
#' \item{skills_sub_domain_score}{Skills score}
#' \item{children_young_people_sub_domain_score}{Children and Young People score}
#' \item{education_skills_and_training_domain_score}{Education, Skills and Training score}
#' \item{skills_sub_domain_rank}{Skills rank}
#' \item{children_young_people_sub_domain_rank}{Children and Young People rank}
#' \item{education_skills_and_training_domain_rank}{Education, Skills and Training rank}
#' \item{skills_sub_domain_decile}{Skills decile}
#' \item{children_young_people_sub_domain_decile}{Children and Young People decile}
#' \item{education_skills_and_training_domain_decile}{Education, Skills and Training decile}
#' \item{wider_barriers_sub_domain_score}{Wider Barriers score}
#' \item{geographical_barriers_sub_domain_score}{Geographical Barriers score}
#' \item{barriers_to_housing_and_services_domain_score}{Barriers to Housing and Services score}
#' \item{wider_barriers_sub_domain_rank}{Wider Barriers rank}
#' \item{geographical_barriers_sub_domain_rank}{Geographical Barriers rank}
#' \item{barriers_to_housing_and_services_domain_rank}{Barriers to Housing and Services rank}
#' \item{wider_barriers_sub_domain_decile}{Wider Barriers decile}
#' \item{geographical_barriers_sub_domain_decile}{Geographical Barriers decile}
#' \item{barriers_to_housing_and_services_domain_decile}{Barriers to Housing and Services decile}
#' \item{indoors_sub_domain_score}{Indoors score}
#' \item{outdoors_sub_domain_score}{Outdoors score}
#' \item{living_environment_domain_score}{Living Environment score}
#' \item{indoors_sub_domain_rank}{Indoors rank}
#' \item{outdoors_sub_domain_rank}{Outdoors ranks}
#' \item{living_environment_domain_rank}{Living Environment rank}
#' \item{indoors_sub_domain_rank_decile}{Indoors decile}
#' \item{outdoors_sub_domain_rank_decile}{Outdoors decile}
#' \item{living_environment_domain_decile}{Living Environment decile}
#' ...
#' }
#' @source \url{https://www.gov.uk/}
"imd2007_england_lsoa01_subdomains"

#' Index of Multiple Deprivation (2007) for Local Authorities in England
#'
#' A data set containing IMD scores, proportions and extents for Local
Expand Down Expand Up @@ -1699,6 +1798,45 @@ NULL
#' @source \url{https://www.gov.uk/}
"imd2004_england_lsoa01"

#' Index of Multiple Deprivation (2004) subdomains for LSOAs in England
#'
#' A data set containing subdomain scores, ranks and deciles for LSOAs in England.
#'
#' @format A data frame of class "tbl" with 32,482 rows and 28 variables:
#' \describe{
#' \item{lsoa01_code}{LSOA (2001) code}
#' \item{skills_sub_domain_score}{Skills score}
#' \item{children_young_people_sub_domain_score}{Children and Young People score}
#' \item{education_skills_and_training_domain_score}{Education, Skills and Training score}
#' \item{skills_sub_domain_rank}{Skills rank}
#' \item{children_young_people_sub_domain_rank}{Children and Young People rank}
#' \item{education_skills_and_training_domain_rank}{Education, Skills and Training rank}
#' \item{skills_sub_domain_decile}{Skills decile}
#' \item{children_young_people_sub_domain_decile}{Children and Young People decile}
#' \item{education_skills_and_training_domain_decile}{Education, Skills and Training decile}
#' \item{wider_barriers_sub_domain_score}{Wider Barriers score}
#' \item{geographical_barriers_sub_domain_score}{Geographical Barriers score}
#' \item{barriers_to_housing_and_services_domain_score}{Barriers to Housing and Services score}
#' \item{wider_barriers_sub_domain_rank}{Wider Barriers rank}
#' \item{geographical_barriers_sub_domain_rank}{Geographical Barriers rank}
#' \item{barriers_to_housing_and_services_domain_rank}{Barriers to Housing and Services rank}
#' \item{wider_barriers_sub_domain_decile}{Wider Barriers decile}
#' \item{geographical_barriers_sub_domain_decile}{Geographical Barriers decile}
#' \item{barriers_to_housing_and_services_domain_decile}{Barriers to Housing and Services decile}
#' \item{indoors_sub_domain_score}{Indoors score}
#' \item{outdoors_sub_domain_score}{Outdoors score}
#' \item{living_environment_domain_score}{Living Environment score}
#' \item{indoors_sub_domain_rank}{Indoors rank}
#' \item{outdoors_sub_domain_rank}{Outdoors ranks}
#' \item{living_environment_domain_rank}{Living Environment rank}
#' \item{indoors_sub_domain_decile}{Indoors decile}
#' \item{outdoors_sub_domain_decile}{Outdoors decile}
#' \item{living_environment_domain_decile}{Living Environment decile}
#' ...
#' }
#' @source \url{https://www.gov.uk/}
"imd2004_england_lsoa01_subdomains"

#' Index of Multiple Deprivation (2004) for Local Authorities in England
#'
#' A data set containing IMD scores, proportions and extents for Local
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
85 changes: 85 additions & 0 deletions data-raw/imd2004_england_lsoa01_subdomains.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
library(tidyverse)
library(devtools)
library(readxl)
library(janitor)
library(compositr)

# Load package
load_all(".")

# Set query url
# query_url <-
# query_urls |>
# filter(data_set == "imd2004_lsoa01_england_subdomains") |>
# pull(query_url)

# Had to download the file and unzip manually
imd2004_education <- read_excel("data-raw/imd2004_england_lsoa01_subdomains.xls", sheet = "Education Skills & Training")
imd2004_barriers <- read_excel("data-raw/imd2004_england_lsoa01_subdomains.xls", sheet = "Barriers to Housing & Services")
imd2004_environment <- read_excel("data-raw/imd2004_england_lsoa01_subdomains.xls", sheet = "Living Environment")

# Select data and calculate ranks and deciles
imd2004_education <-
imd2004_education |>
clean_names() |>
select(
lsoa01_code = soa_code,
skills_sub_domain_score,
children_young_people_sub_domain_score,
education_skills_and_training_domain_score
) |>
mutate(
skills_sub_domain_rank = invert_rank(skills_sub_domain_score),
children_young_people_sub_domain_rank = invert_rank(children_young_people_sub_domain_score),
education_skills_and_training_domain_rank = invert_rank(education_skills_and_training_domain_score),

skills_sub_domain_decile = ntile(skills_sub_domain_rank, n = 10),
children_young_people_sub_domain_decile = ntile(children_young_people_sub_domain_rank, n = 10),
education_skills_and_training_domain_decile = ntile(education_skills_and_training_domain_rank, n = 10)
)

imd2004_barriers <-
imd2004_barriers |>
clean_names() |>
select(
lsoa01_code = soa_code,
wider_barriers_sub_domain_score,
geographical_barriers_sub_domain_score,
barriers_to_housing_and_services_domain_score
) |>
mutate(
wider_barriers_sub_domain_rank = invert_rank(wider_barriers_sub_domain_score),
geographical_barriers_sub_domain_rank = invert_rank(geographical_barriers_sub_domain_score),
barriers_to_housing_and_services_domain_rank = invert_rank(barriers_to_housing_and_services_domain_score),

wider_barriers_sub_domain_decile = ntile(wider_barriers_sub_domain_rank, n = 10),
geographical_barriers_sub_domain_decile = ntile(geographical_barriers_sub_domain_rank, n = 10),
barriers_to_housing_and_services_domain_decile = ntile(barriers_to_housing_and_services_domain_rank, n = 10)
)

imd2004_environment <-
imd2004_environment |>
clean_names() |>
select(
lsoa01_code = soa_code,
indoors_sub_domain_score = indoors_sub_domain,
outdoors_sub_domain_score = outdoors_sub_domain,
living_environment_domain_score = living_environment_domain
) |>
mutate(
indoors_sub_domain_rank = invert_rank(indoors_sub_domain_score),
outdoors_sub_domain_rank = invert_rank(outdoors_sub_domain_score),
living_environment_domain_rank = invert_rank(living_environment_domain_score),

indoors_sub_domain_decile = ntile(indoors_sub_domain_rank, n = 10),
outdoors_sub_domain_decile = ntile(outdoors_sub_domain_rank, n = 10),
living_environment_domain_decile = ntile(living_environment_domain_score, n = 10)
)

imd2004_england_lsoa01_subdomains <-
imd2004_education |>
left_join(imd2004_barriers) |>
left_join(imd2004_environment)

# Save output to data/ folder
usethis::use_data(imd2004_england_lsoa01_subdomains, overwrite = TRUE)
Binary file added data-raw/imd2004_england_lsoa01_subdomains.xls
Binary file not shown.
85 changes: 85 additions & 0 deletions data-raw/imd2007_england_lsoa01_subdomains.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
library(tidyverse)
library(devtools)
library(readxl)
library(janitor)
library(compositr)

# Load package
load_all(".")

# Set query url
# query_url <-
# query_urls |>
# filter(data_set == "imd2007_lsoa01_england_subdomains") |>
# pull(query_url)

# Had to download the file and unzip manually
imd2007_education <- read_excel("data-raw/imd2007_england_lsoa01_subdomains.xls", sheet = "Education Skills & Training")
imd2007_barriers <- read_excel("data-raw/imd2007_england_lsoa01_subdomains.xls", sheet = "Barriers to Housing & Services")
imd2007_environment <- read_excel("data-raw/imd2007_england_lsoa01_subdomains.xls", sheet = "Living Environment")

# Select data and calculate ranks and deciles
imd2007_education <-
imd2007_education |>
clean_names() |>
select(
lsoa01_code = lsoa_code,
skills_sub_domain_score,
children_young_people_sub_domain_score,
education_skills_and_training_domain_score
) |>
mutate(
skills_sub_domain_rank = invert_rank(skills_sub_domain_score),
children_young_people_sub_domain_rank = invert_rank(children_young_people_sub_domain_score),
education_skills_and_training_domain_rank = invert_rank(education_skills_and_training_domain_score),

skills_sub_domain_decile = ntile(skills_sub_domain_rank, n = 10),
children_young_people_sub_domain_decile = ntile(children_young_people_sub_domain_rank, n = 10),
education_skills_and_training_domain_decile = ntile(education_skills_and_training_domain_rank, n = 10)
)

imd2007_barriers <-
imd2007_barriers |>
clean_names() |>
select(
lsoa01_code = lsoa_code,
wider_barriers_sub_domain_score,
geographical_barriers_sub_domain_score,
barriers_to_housing_and_services_domain_score
) |>
mutate(
wider_barriers_sub_domain_rank = invert_rank(wider_barriers_sub_domain_score),
geographical_barriers_sub_domain_rank = invert_rank(geographical_barriers_sub_domain_score),
barriers_to_housing_and_services_domain_rank = invert_rank(barriers_to_housing_and_services_domain_score),

wider_barriers_sub_domain_decile = ntile(wider_barriers_sub_domain_rank, n = 10),
geographical_barriers_sub_domain_decile = ntile(geographical_barriers_sub_domain_rank, n = 10),
barriers_to_housing_and_services_domain_decile = ntile(barriers_to_housing_and_services_domain_rank, n = 10)
)

imd2007_environment <-
imd2007_environment |>
clean_names() |>
select(
lsoa01_code = lsoa_code,
indoors_sub_domain_score = indoors_sub_domain,
outdoors_sub_domain_score = outdoors_sub_domain,
living_environment_domain_score = living_environment_domain
) |>
mutate(
indoors_sub_domain_rank = invert_rank(indoors_sub_domain_score),
outdoors_sub_domain_rank = invert_rank(outdoors_sub_domain_score),
living_environment_domain_rank = invert_rank(living_environment_domain_score),

indoors_sub_domain_rank_decile = ntile(indoors_sub_domain_rank, n = 10),
outdoors_sub_domain_rank_decile = ntile(outdoors_sub_domain_rank, n = 10),
living_environment_domain_decile = ntile(living_environment_domain_score, n = 10)
)

imd2007_england_lsoa01_subdomains <-
imd2007_education |>
left_join(imd2007_barriers) |>
left_join(imd2007_environment)

# Save output to data/ folder
usethis::use_data(imd2007_england_lsoa01_subdomains, overwrite = TRUE)
Binary file added data-raw/imd2007_england_lsoa01_subdomains.xls
Binary file not shown.
34 changes: 34 additions & 0 deletions data-raw/imd2010_england_lsoa01_subdomains.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library(tidyverse)
library(devtools)
library(janitor)

# Load package
load_all(".")

# Set query url
query_url <-
query_urls |>
filter(data_set == "imd2010_lsoa01_england") |>
pull(query_url)

imd2010 <- read_csv(query_url)

imd2010_england_lsoa01_subdomains <-
imd2010 |>
select(
lsoa01_code = `LSOA CODE`,
contains("Sub-domain")
) |>
rename_with(~ str_remove(.x, fixed(" (where 1 is most deprived)"))) |>
clean_names() |>
mutate(
indoors_sub_domain_decile = ntile(indoors_sub_domain_rank, n = 10),
outdoors_sub_domain_decile = ntile(outdoors_sub_domain_rank, n = 10),
geographical_barriers_sub_domain_decile = ntile(geographical_barriers_sub_domain_rank, n = 10),
wider_barriers_sub_domain_decile = ntile(wider_barriers_sub_domain_rank, n = 10),
children_young_people_sub_domain_decile = ntile(children_young_people_sub_domain_rank, n = 10),
skills_sub_domain_decile = ntile(skills_sub_domain_rank, n = 10)
)

# Save output to data/ folder
usethis::use_data(imd2010_england_lsoa01_subdomains, overwrite = TRUE)
Loading