Skip to content

Commit

Permalink
add variable labels (#33)
Browse files Browse the repository at this point in the history
* add labelled package

* add labels
  • Loading branch information
eveyp authored Aug 6, 2021
1 parent 9688378 commit 8ae907d
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 2 deletions.
47 changes: 47 additions & 0 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,50 @@ save_maps = function(maps, output_dir = "maps") {
# invisibly return the file path so targets can track it
invisible(output_file)
}

label_dataset = function(data) {
data %>%
set_variable_labels(
coc_number = "CoC number",
coc_name = "CoC name",
coc_category = "CoC category",
year = "Year",
overall_homeless = "Unhoused people",
homeless_rate_total_pop = "Homelessness rate",
homeless_rate_in_poverty = "Homelessness rate (poverty)",
homeless_per_1000_total_pop = "Unhoused people per 1,000 people",
homeless_per_1000_in_poverty = "Unhoused people per 1,000 people (poverty)",
coc_pop = "Population",
coc_poverty_pop = "Population below poverty line",
coc_poverty_rate = "Poverty rate",
avg_renter_share = "Rental household share",
share_rent_over_30_pct_inc = "% rent-burdened (30%)",
share_rent_over_50_pct_inc = "% extremely rent burdened (50%)",
median_rent_burden = "Median rent burden",
gross_vacancy_rate = "Gross vacancy rate",
rental_vacancy_rate = "Rental vacancy rate",
eviction_filings = "Eviction filings",
evictions = "Evictions",
eviction_filing_rate = "Eviction filing rate",
eviction_rate = "Eviction rate",
missing_evictions_rate = "% of CoC missing eviction data",
avg_fmr0 = "Avg. studio FMR",
avg_fmr1 = "Avg. 1-bedroom FMR",
avg_fmr2 = "Avg. 2-bedroom FMR",
avg_fmr3 = "Avg. 3-bedroom FMR",
avg_fmr4 = "Avg. 4-bedroom FMR",
pct_coc_na_fmr = "% of CoC missing FMR",
coc_rent_zillow = "Avg. Zillow Rent Index",
coc_share_na_rent_zillow = "% of CoC missing Zillow Rent Index",
coc_unemployment_rate = "Unemployment rate",
share_na_coc_unemployment_rate = "% of population missing unemployment rate",
shr_hh_with_snap = "% with SNAP",
shr_hh_with_pub_assist = "% with public assistance",
shr_hh_with_snap_or_pub_assist = "% with SNAP or public assistance",
shr_hh_with_ssi = "% with SSI",
shr_with_medicaid = "% with Medicaid",
household_income = "Median household income",
family_income = "Median family income",
individual_earnings = "Median individual earnings"
)
}
6 changes: 4 additions & 2 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ tar_option_set(
"readxl",
"haven",
"rmapshaper",
"maptools"
"maptools",
"labelled"
)
)

Expand Down Expand Up @@ -257,7 +258,8 @@ list(
full_join(coc_unemployment_rate, by = c("coc_number", "year")) %>%
full_join(coc_public_program_use, by = c("coc_number", "year")) %>%
full_join(coc_evictions, by = c("coc_number", "year")) %>%
full_join(coc_income, by = c("coc_number", "year"))
full_join(coc_income, by = c("coc_number", "year")) %>%
label_dataset()
),
#### Output Dataset Files ####
tar_map(
Expand Down
63 changes: 63 additions & 0 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,13 @@
"Repository": "CRAN",
"Hash": "13641a1c6d2cc98801b76764078e17ea"
},
"httpuv": {
"Package": "httpuv",
"Version": "1.6.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "54344a78aae37bc6ef39b1240969df8e"
},
"httr": {
"Package": "httr",
"Version": "1.4.2",
Expand Down Expand Up @@ -749,6 +756,20 @@
"Repository": "CRAN",
"Hash": "3d5108641f47470611a32d0bdf357a72"
},
"labelled": {
"Package": "labelled",
"Version": "2.8.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "41e3b9df8e07dba367a58462cc328721"
},
"later": {
"Package": "later",
"Version": "1.2.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "b61890ae77fea19fc8acadd25db70aa4"
},
"lattice": {
"Package": "lattice",
"Version": "0.20-41",
Expand Down Expand Up @@ -875,6 +896,13 @@
"Repository": "CRAN",
"Hash": "f4dbc5a47fd93d3415249884d31d6791"
},
"packrat": {
"Package": "packrat",
"Version": "0.6.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "0d6cc4c357e7602bb3eee299f4cfc2a5"
},
"parallelly": {
"Package": "parallelly",
"Version": "1.25.0",
Expand Down Expand Up @@ -972,6 +1000,13 @@
"Repository": "CRAN",
"Hash": "14dc9f7a3c91ebb14ec5bb9208a07061"
},
"promises": {
"Package": "promises",
"Version": "1.2.0.1",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "4ab2c43adb4d4699cf3690acd378d75d"
},
"protolite": {
"Package": "protolite",
"Version": "2.1",
Expand Down Expand Up @@ -1159,6 +1194,13 @@
"Repository": "CRAN",
"Hash": "249d8cd1e74a8f6a26194a91b47f21d1"
},
"rsconnect": {
"Package": "rsconnect",
"Version": "0.8.18",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "50b4e52011e335f7d3053cfde69893ba"
},
"rstudioapi": {
"Package": "rstudioapi",
"Version": "0.13",
Expand Down Expand Up @@ -1236,6 +1278,13 @@
"Repository": "CRAN",
"Hash": "c1bd5fbd6bed3c16a20df15d9bc20c55"
},
"shiny": {
"Package": "shiny",
"Version": "1.6.0",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "6e3b6ae7fe02b5859e4bb277f218b8ae"
},
"showtext": {
"Package": "showtext",
"Version": "0.9-2",
Expand All @@ -1250,6 +1299,13 @@
"Repository": "CRAN",
"Hash": "c12e756cf947e58b0f2c2a520521a5a8"
},
"sourcetools": {
"Package": "sourcetools",
"Version": "0.1.7",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "947e4e02a79effa5d512473e10f41797"
},
"sp": {
"Package": "sp",
"Version": "1.4-5",
Expand Down Expand Up @@ -1495,6 +1551,13 @@
"Repository": "CRAN",
"Hash": "6c85f015dee9cc7710ddd20f86881f58"
},
"xtable": {
"Package": "xtable",
"Version": "1.8-4",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "b8acdf8af494d9ec19ccb2481a9b11c2"
},
"yaml": {
"Package": "yaml",
"Version": "2.2.1",
Expand Down

0 comments on commit 8ae907d

Please sign in to comment.