Skip to content

Commit

Permalink
correct minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
david-beauchesne committed May 24, 2023
1 parent e184278 commit cbf5c10
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 91 deletions.
2 changes: 1 addition & 1 deletion R/pipeplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ plotingrid <- function(res, width, height, pal) {
# Filenames
filenames <- meta$ingrid$files

for(j in 1:length(dat)) {
for(j in 1:length(filenames$filenames)) {
# Name
nm <- filenames$filenames[j]
sub <- filenames$names[j]
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
Binary file modified inst/extdata/pipeline_code.rda
Binary file not shown.
3 changes: 1 addition & 2 deletions inst/pipelines/aboriginal_lands_canada-6eefac0b.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ dp_6eefac0b <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
dat <- list()
dat[[1]] <- masterload(here::here(path, "raw", "AL_TA_CA_2_152_MODIFIED_eng.shp"))
dat[[2]] <- masterload(here::here(path, "raw", "AL_TA_CA_2_152_CONFIRMED_eng.shp"))

dat <- dplyr::bind_rows(dat)

# Subset data (if specified by user)
# on.exit(sf::sf_use_s2(TRUE), add = TRUE)
# sf::sf_use_s2(FALSE)
dat <- lapply(dat, dp_parameters, bbox = bbox, timespan = timespan)
dat <- dp_parameters(dat, bbox = bbox, timespan = timespan)

# Export
fm <- here::here(path,"format",nm)
Expand Down
97 changes: 34 additions & 63 deletions inst/pipelines/canadian_vulnerabilities_census-8671c3e4.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,23 @@ dp_8671c3e4 <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# Metadata
meta <- get_metadata(
pipeline_type = "data",
pipeline_id = uid,
access = timestamp()
)

# bibtex
bib <- get_bib(uid)
if (!file.exists(here::here(path, glue::glue("{nm}.yaml")))) {
# Metadata
meta <- get_metadata(
pipeline_type = "data",
pipeline_id = uid,
access = timestamp()
)

# bibtex
bib <- get_bib(uid)

# Export
mt <- here::here(path, nm)
masterwrite(meta, mt)
masterwrite(bib, mt)
write_pipeline(uid)
# Export
mt <- here::here(path, nm)
masterwrite(meta, mt)
masterwrite(bib, mt)
write_pipeline(uid)
}
}
# _________________________________________________________________________________________ #

Expand All @@ -67,7 +69,7 @@ dp_8671c3e4 <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
dplyr::select(DGUID)
}

# Census 2021 housing suitability
# Census 2021
census <- importdat("37563350", "format")[[1]]

# List to store data
Expand Down Expand Up @@ -172,9 +174,9 @@ dp_8671c3e4 <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
statement <- c(
"census cartographic divisions and subdivisions boundary files for 2021 [@statisticscanada2022f; statisticscanada2022]",
"census cartographic divisions boundary files for 2021 [@statisticscanada2022f; statisticscanada2022]",
"census cartographic subdivisions boundary files for 2021 [@statisticscanada2022f; statisticscanada2022]"
"census cartographic divisions and subdivisions boundary files for 2021 [@statisticscanada2022f; @statisticscanada2022]",
"census cartographic divisions boundary files for 2021 [@statisticscanada2022f; @statisticscanada2022]",
"census cartographic subdivisions boundary files for 2021 [@statisticscanada2022f; @statisticscanada2022]"
)
geos <- dplyr::case_when(
"division" %in% census_geo_8671c3e4 &
Expand All @@ -186,50 +188,19 @@ dp_8671c3e4 <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
add_format(
format = list(
timestamp = timestamp(),
description = '
Data from the 2021 Census of Population [@statisticscanada2021a] was used to select relevant population indicators as proxies of social vulnerabilities. The indicators were then joined to the {geos} and subsequently integrated in the study grid. The selected indicators are: <br>
<table>
<tr>
<th>Indicator</th>
<th>Description</th>
</tr>
<tr>
<td>Gini index on adjusted household total income</td>
<td>The Gini coefficient is a number between zero and one that measures the relative degree of inequality in the distribution of income. The coefficient would register zero (minimum inequality) for a population in which each person received exactly the same adjusted household income and it would register a coefficient of one (maximum inequality) if one person received all the adjusted household income and the rest received none. Even though a single Gini coefficient value has no simple interpretation, comparisons of the level over time or between populations are very straightforward: the higher the coefficient, the higher the inequality of the distribution.</td>
</tr>
<tr>
<td>P90/P10 ratio on adjusted household after-tax income</td>
<td>The P90/P10 ratio is a measure of inequality. It is the ratio of the 90th and the 10th percentile of the adjusted household after-tax income. The 90th percentile means 90% of the population has income that falls below this threshold. The 10th percentile means 10% of the population has income that falls below this threshold.</td>
</tr>
<tr>
<td>Prevalence of low income based on the Low-income measure, after tax (LIM-AT) (%)"</td>
<td>The Low‑income measure, after tax, refers to a fixed percentage (50%) of median adjusted after‑tax income of private households. The household after‑tax income is adjusted by an equivalence scale to take economies of scale into account. This adjustment for different household sizes reflects the fact that a household\'s needs increase, but at a decreasing rate, as the number of members increases.</td>
</tr>
<tr>
<td>Prevalence of low income based on the Low-income cut-offs, after tax (LICO-AT) (%)"</td>
<td>The Low‑income cut‑offs, after tax refer to income thresholds, defined using 1992 expenditure data, below which economic families or persons not in economic families would likely have devoted a larger share of their after‑tax income than average to the necessities of food, shelter and clothing. More specifically, the thresholds represented income levels at which these families or persons were expected to spend 20 percentage points or more of their after‑tax income than average on food, shelter and clothing. These thresholds have been adjusted to current dollars using the all‑items Consumer Price Index (CPI).</td>
</tr>
<tr>
<td>Indigenous identity</td>
<td>Indigenous identity refers to whether the person identified with the Indigenous peoples of Canada. This includes those who identify as First Nations (North American Indian), Métis and/or Inuk (Inuit), and/or those who report being Registered or Treaty Indians (that is, registered under the Indian Act of Canada), and/or those who have membership in a First Nation or Indian band. Aboriginal peoples of Canada (referred to here as Indigenous peoples) are defined in the Constitution Act, 1982, Section 35 (2) as including the Indian, Inuit and Métis peoples of Canada.</td>
</tr>
<tr>
<td>In a one-parent family</td>
<td>Percent children living in one-parent family</td>
</tr>
<tr>
<td>Parents in one-parent families</td>
<td>Percent parent in one-parent family</td>
</tr>
<tr>
<td>No certificate, diploma or degree</td>
<td>Percent population with no certificate, diploma or degree, population 25-64 years old</td>
</tr>
<tr>
<td>Government transfers (%)</td>
<td>Percent of total income composed of government transfers in 2020, corresponding to all cash benefits received from federal, provincial, territorial or municipal governments during the reference period.</td>
</tr>
</table>',
description = glue::glue(
'Data from the 2021 Census of Population [@statisticscanada2021a] was used to select relevant population indicators as proxies of social vulnerabilities. The indicators were then joined to the {geos} and subsequently integrated in the study grid. The selected indicators are:
- ***Gini index on adjusted household total income***: *The Gini coefficient is a number between zero and one that measures the relative degree of inequality in the distribution of income. The coefficient would register zero (minimum inequality) for a population in which each person received exactly the same adjusted household income and it would register a coefficient of one (maximum inequality) if one person received all the adjusted household income and the rest received none. Even though a single Gini coefficient value has no simple interpretation, comparisons of the level over time or between populations are very straightforward: the higher the coefficient, the higher the inequality of the distribution.*
- ***P90/P10 ratio on adjusted household after-tax incom***: *The P90/P10 ratio is a measure of inequality. It is the ratio of the 90th and the 10th percentile of the adjusted household after-tax income. The 90th percentile means 90% of the population has income that falls below this threshold. The 10th percentile means 10% of the population has income that falls below this threshold.*
- ***Prevalence of low income based on the Low-income measure, after tax (LIM-AT) (%)***: *The Low‑income measure, after tax, refers to a fixed percentage (50%) of median adjusted after‑tax income of private households. The household after‑tax income is adjusted by an equivalence scale to take economies of scale into account. This adjustment for different household sizes reflects the fact that a household\'s needs increase, but at a decreasing rate, as the number of members increases.*
- ***Prevalence of low income based on the Low-income cut-offs, after tax (LICO-AT) (%)***: *The Low‑income cut‑offs, after tax refer to income thresholds, defined using 1992 expenditure data, below which economic families or persons not in economic families would likely have devoted a larger share of their after‑tax income than average to the necessities of food, shelter and clothing. More specifically, the thresholds represented income levels at which these families or persons were expected to spend 20 percentage points or more of their after‑tax income than average on food, shelter and clothing. These thresholds have been adjusted to current dollars using the all‑items Consumer Price Index (CPI).*
- ***Indigenous identity***: *Indigenous identity refers to whether the person identified with the Indigenous peoples of Canada. This includes those who identify as First Nations (North American Indian), Métis and/or Inuk (Inuit), and/or those who report being Registered or Treaty Indians (that is, registered under the Indian Act of Canada), and/or those who have membership in a First Nation or Indian band. Aboriginal peoples of Canada (referred to here as Indigenous peoples) are defined in the Constitution Act, 1982, Section 35 (2) as including the Indian, Inuit and Métis peoples of Canada.*
- ***In a one-parent family***: *Percent children living in one-parent family*
- ***Parents in one-parent families***: *Percent parent in one-parent family
- ***No certificate, diploma or degree***: *Percent population with no certificate, diploma or degree, population 25-64 years old*
- ***Government transfers (%)***: *Percent of total income composed of government transfers in 2020, corresponding to all cash benefits received from federal, provincial, territorial or municipal governments during the reference period.*'
),
filenames = files
)
)
Expand Down Expand Up @@ -309,7 +280,7 @@ dp_8671c3e4 <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
"percent_government_transfers"
)
)
filenames <- glue::glue('{nm}-{sort(census_geo_8671c3e4)}')
filenames <- glue::glue('{nm}-census_{sort(census_geo_8671c3e4)}')
meta <- load_metadata(path, nm) |>
add_ingrid(
ingrid = list(
Expand Down
2 changes: 1 addition & 1 deletion inst/pipelines/census_acceptable_housing_2021-f4abec86.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dp_f4abec86 <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
format = list(
timestamp = timestamp(),
description = "No modifications applied to the data; simple export of raw data.",
filenames = basename(fm)
filenames = nm
)
)
masterwrite(meta, here::here(path, nm))
Expand Down
26 changes: 3 additions & 23 deletions inst/pipelines/census_road_network_file_2021-7daa23ee.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ dp_7daa23ee <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
dist_rd <- dplyr::bind_rows(noroads, yesroads)
rd <- dplyr::left_join(rd, dist_rd, by = "id") |>
dplyr::select(x,y,distance_roads) |>
stars::st_as_stars(coords = c("x","y"), crs = sf::st_crs(r))

stars::st_as_stars(coords = c("x","y"))
sf::st_crs(rd) <- sf::st_crs(r)

# Export
masterwrite(rd, here::here(path, "ingrid", glue::glue("{nm}-distance_to_road_network")))

Expand All @@ -218,27 +219,6 @@ dp_7daa23ee <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
}
# _________________________________________________________________________________________ #

# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
# Metadata & bibtex
# =~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~= #
# Metadata
meta <- get_metadata(
pipeline_type = "data",
pipeline_id = uid,
pipeline_bbox = bbox,
pipeline_timespan = timespan,
access = timestamp()
)

# bibtex
bib <- get_bib(uid)

# Export
mt <- here::here(path, nm)
masterwrite(meta, mt)
masterwrite(bib, mt)
write_pipeline(uid)

# Clean
clean_path(uid)
# _________________________________________________________________________________________ #
Expand Down
2 changes: 1 addition & 1 deletion inst/pipelines/housing_acceptability_canada-175ec912.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ dp_175ec912 <- function(bbox = NULL, bbox_crs = NULL, timespan = NULL, ingrid =
add_format(
format = list(
timestamp = timestamp(),
description = 'Data from housing suitability [@statisticscanada2022c], dwelling condition [@statisticscanada2022d], and acceptable housing [@statisticscanada2022e] of the 2021 Census of Population [@statisticscanada2021a] were joined with the 2021 Census cartographic division boundary file [@statisticscanada2022; statisticscanada2022f]. <br> According to Statistics Canada housing suitability *"refers to whether a private household is living in suitable accommodations according to the National Occupancy Standard (NOS); that is, whether the dwelling has enough bedrooms for the size and composition of the household. A household is deemed to be living in suitable accommodations if its dwelling has enough bedrooms, as calculated using the NOS. Housing suitability assesses the required number of bedrooms for a household based on the age, sex, and relationships among household members. An alternative variable, persons per room, considers all rooms in a private dwelling and the number of household members. Housing suitability and the National Occupancy Standard (NOS) on which it is based were developed by Canada Mortgage and Housing Corporation (CMHC) through consultations with provincial housing agencies."* Housing suitability was assessed as the proportion of households in a census division considered as not suitable. <br> Dwelling condition refers to whether the dwelling is in need of repairs. Acceptability of dwelling condition was assessed as the proportion of households in a census division considered as needing major repairs. <br> According to Statistics Canada, acceptable housing *"refers to whether a household meets each of the three indicator thresholds established by the Canada Mortgage and Housing Corporation for housing adequacy, suitability and affordability. Housing indicator thresholds are defined as follows: 1) adequate housing is reported by their residents as not requiring any major repairs; 2) affordable housing has shelter costs less than 30% of total before-tax household income; 3) suitable housing has enough bedrooms for the size and composition of resident households according to the National Occupancy Standard (NOS), conceived by the Canada Mortgage and Housing Corporation and provincial and territorial representatives. Acceptable housing identifies which thresholds the household falls below, if any. Housing that is adequate in condition, suitable in size and affordable is considered to be acceptable."* Here, acceptable housing was assessed as the proportion of households in a census division that was below any of the thresholds of adequacy, affordability or suitability.',
description = 'Data from housing suitability [@statisticscanada2022c], dwelling condition [@statisticscanada2022d], and acceptable housing [@statisticscanada2022e] of the 2021 Census of Population [@statisticscanada2021a] were joined with the 2021 Census cartographic division boundary file [@statisticscanada2022; @statisticscanada2022f]. <br> According to Statistics Canada housing suitability *"refers to whether a private household is living in suitable accommodations according to the National Occupancy Standard (NOS); that is, whether the dwelling has enough bedrooms for the size and composition of the household. A household is deemed to be living in suitable accommodations if its dwelling has enough bedrooms, as calculated using the NOS. Housing suitability assesses the required number of bedrooms for a household based on the age, sex, and relationships among household members. An alternative variable, persons per room, considers all rooms in a private dwelling and the number of household members. Housing suitability and the National Occupancy Standard (NOS) on which it is based were developed by Canada Mortgage and Housing Corporation (CMHC) through consultations with provincial housing agencies."* Housing suitability was assessed as the proportion of households in a census division considered as not suitable. <br> Dwelling condition refers to whether the dwelling is in need of repairs. Acceptability of dwelling condition was assessed as the proportion of households in a census division considered as needing major repairs. <br> According to Statistics Canada, acceptable housing *"refers to whether a household meets each of the three indicator thresholds established by the Canada Mortgage and Housing Corporation for housing adequacy, suitability and affordability. Housing indicator thresholds are defined as follows: 1) adequate housing is reported by their residents as not requiring any major repairs; 2) affordable housing has shelter costs less than 30% of total before-tax household income; 3) suitable housing has enough bedrooms for the size and composition of resident households according to the National Occupancy Standard (NOS), conceived by the Canada Mortgage and Housing Corporation and provincial and territorial representatives. Acceptable housing identifies which thresholds the household falls below, if any. Housing that is adequate in condition, suitable in size and affordable is considered to be acceptable."* Here, acceptable housing was assessed as the proportion of households in a census division that was below any of the thresholds of adequacy, affordability or suitability.',
filenames = basename(fm)
)
)
Expand Down

0 comments on commit cbf5c10

Please sign in to comment.