-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3078e34
commit 393709c
Showing
7 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# ---- Load libs ---- | ||
library(tidyverse) | ||
library(geographr) | ||
library(devtools) | ||
library(httr2) | ||
|
||
# ---- Load internal sysdata.rda file with URLs ---- | ||
load_all(".") | ||
|
||
# ---- Download data ---- | ||
query_url <- | ||
query_urls |> | ||
filter(id == "religion") |> | ||
pull(query) | ||
|
||
download <- tempfile(fileext = ".zip") | ||
|
||
request(query_url) |> | ||
req_perform(download) | ||
|
||
unzip(download, exdir = tempdir()) | ||
|
||
list.files(tempdir()) | ||
|
||
raw_lsoa21 <- read_csv(file.path(tempdir(), "census2021-ts030-lsoa.csv")) | ||
|
||
names(raw_lsoa21) <- str_remove(names(raw_lsoa21), "Religion: ") | ||
|
||
# ---- Detailed ethnic categories ---- | ||
religion21_lsoa21 <- | ||
raw_lsoa21 |> | ||
select(lsoa21_code = `geography code`, total_residents = `Total: All usual residents`, !contains(":"), -date, -geography) |> | ||
pivot_longer(cols = -c(lsoa21_code, total_residents), names_to = "religion", values_to = "n") |> | ||
mutate(prop = n / total_residents) | ||
|
||
# ---- Save output to data/ folder ---- | ||
usethis::use_data(religion21_lsoa21, overwrite = TRUE) |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.