mirror of
https://github.com/kidwellj/hacking_religion_textbook.git
synced 2025-06-15 08:44:09 +00:00
updated ch1
This commit is contained in:
parent
8ad4dca354
commit
34f7797b2a
7 changed files with 256 additions and 73 deletions
|
@ -201,10 +201,11 @@ Here's the process to identify a dataset within the nomis platform:
|
|||
```{r}
|
||||
# Process to explore nomis() data for specific datasets
|
||||
library(nomisr)
|
||||
religion_search <- nomis_search(name = "*Religion*")
|
||||
religion_measures <- nomis_get_metadata("ST104", "measures")
|
||||
tibble::glimpse(religion_measures)
|
||||
religion_geography <- nomis_get_metadata("NM_529_1", "geography", "TYPE")
|
||||
# temporarily commenting out until renv can be implemented and runtime errors in other environments avoided:
|
||||
#religion_search <- nomis_search(name = "*Religion*")
|
||||
#religion_measures <- nomis_get_metadata("ST104", "measures")
|
||||
#tibble::glimpse(religion_measures)
|
||||
#religion_geography <- nomis_get_metadata("NM_529_1", "geography", "TYPE")
|
||||
```
|
||||
|
||||
:::
|
||||
|
@ -212,9 +213,12 @@ religion_geography <- nomis_get_metadata("NM_529_1", "geography", "TYPE")
|
|||
|
||||
```{r}
|
||||
library(nomisr)
|
||||
|
||||
# Get table of Census 2011 religion data from nomis
|
||||
z <- nomis_get_data(id = "NM_529_1", time = "latest", geography = "TYPE499", measures=c(20301))
|
||||
# temporarily commenting out until renv can be implemented and runtime errors in other environments avoided:
|
||||
#z <- nomis_get_data(id = "NM_529_1", time = "latest", geography = "TYPE499", measures=c(20301))
|
||||
#saveRDS(z, file = "z.rds")
|
||||
z <- readRDS(file = (here("example_data", "z.rds")))
|
||||
|
||||
# Filter down to simplified dataset with England / Wales and percentages without totals
|
||||
uk_census_2011_religion <- filter(z, GEOGRAPHY_NAME=="England and Wales" & RURAL_URBAN_NAME=="Total" & C_RELPUK11_NAME != "All categories: Religion")
|
||||
# Drop unnecessary columns
|
||||
|
@ -225,7 +229,11 @@ plot1 <- ggplot(uk_census_2011_religion, aes(x = C_RELPUK11_NAME, y = OBS_VALUE)
|
|||
|
||||
# grab daata from nomis for 2001 census religion / ethnicity
|
||||
|
||||
z0 <- nomis_get_data(id = "NM_1872_1", time = "latest", geography = "TYPE499", measures=c(20100))
|
||||
# temporarily commenting out until renv can be implemented and runtime errors in other environments avoided:
|
||||
#z0 <- nomis_get_data(id = "NM_1872_1", time = "latest", geography = "TYPE499", measures=c(20100))
|
||||
#saveRDS(z0, file = "z0.rds")
|
||||
z0 <- readRDS(file = (here("example_data", "z0.rds")))
|
||||
|
||||
# select relevant columns
|
||||
uk_census_2001_religion_ethnicity <- select(z0, GEOGRAPHY_NAME, C_RELPUK11_NAME, C_ETHHUK11_NAME, OBS_VALUE)
|
||||
# Filter down to simplified dataset with England / Wales and percentages without totals
|
||||
|
@ -234,7 +242,11 @@ uk_census_2001_religion_ethnicity <- filter(uk_census_2001_religion_ethnicity, G
|
|||
uk_census_2001_religion_ethnicity <- uk_census_2001_religion_ethnicity %>% filter(grepl('Total', C_ETHHUK11_NAME))
|
||||
|
||||
# grab data from nomis for 2011 census religion / ethnicity table
|
||||
z1 <- nomis_get_data(id = "NM_659_1", time = "latest", geography = "TYPE499", measures=c(20100))
|
||||
# commenting out nomis_get temporarily until I can get renv working properly here
|
||||
#z1 <- nomis_get_data(id = "NM_659_1", time = "latest", geography = "TYPE499", measures=c(20100))
|
||||
#saveRDS(z1, file = "z1.rds")
|
||||
z1 <- readRDS(file = (here("example_data", "z1.rds")))
|
||||
|
||||
# select relevant columns
|
||||
uk_census_2011_religion_ethnicity <- select(z1, GEOGRAPHY_NAME, C_RELPUK11_NAME, C_ETHPUK11_NAME, OBS_VALUE)
|
||||
# Filter down to simplified dataset with England / Wales and percentages without totals
|
||||
|
@ -243,7 +255,10 @@ uk_census_2011_religion_ethnicity <- filter(uk_census_2011_religion_ethnicity, G
|
|||
uk_census_2011_religion_ethnicity <- uk_census_2011_religion_ethnicity %>% filter(grepl('Total', C_ETHPUK11_NAME))
|
||||
|
||||
# grab data from nomis for 2021 census religion / ethnicity table
|
||||
z2 <- nomis_get_data(id = "NM_2131_1", time = "latest", geography = "TYPE499", measures=c(20100))
|
||||
#z2 <- nomis_get_data(id = "NM_2131_1", time = "latest", geography = "TYPE499", measures=c(20100))
|
||||
#saveRDS(z2, file = "z2.rds")
|
||||
z2 <- readRDS(file = (here("example_data", "z2.rds")))
|
||||
|
||||
# select relevant columns
|
||||
uk_census_2021_religion_ethnicity <- select(z2, GEOGRAPHY_NAME, C2021_RELIGION_10_NAME, C2021_ETH_8_NAME, OBS_VALUE)
|
||||
# Filter down to simplified dataset with England / Wales and percentages without totals
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue