├── docs ├── .nojekyll ├── favicon.ico ├── favicon-16x16.png ├── favicon-32x32.png ├── apple-touch-icon.png ├── extra.css ├── apple-touch-icon-60x60.png ├── apple-touch-icon-76x76.png ├── reference │ ├── figures │ │ └── logo.png │ ├── cmhc_ct_translation_data.html │ ├── cmhc_cma_translation_data.html │ ├── cmhc_csd_translation_data.html │ ├── cmhc_csd_translation_data_2023.html │ ├── show_cmhc_cache_path.html │ ├── cmhc_quality_labels.html │ ├── select_cmhc_table.html │ ├── list_cmhc_surveys.html │ ├── list_cmhc_series.html │ ├── list_cmhc_dimensions.html │ ├── list_cmhc_filters.html │ └── set_cmhc_cache_path.html ├── apple-touch-icon-120x120.png ├── apple-touch-icon-152x152.png ├── apple-touch-icon-180x180.png ├── articles │ ├── basic_usage_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-5-1.png │ │ │ ├── unnamed-chunk-6-1.png │ │ │ ├── unnamed-chunk-7-1.png │ │ │ └── unnamed-chunk-8-1.png │ ├── rental_universe_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-3-1.png │ │ │ ├── unnamed-chunk-4-1.png │ │ │ └── unnamed-chunk-5-1.png │ └── index.html ├── pkgdown.yml ├── link.svg ├── bootstrap-toc.css ├── docsearch.js ├── sitemap.xml ├── pkgdown.js ├── bootstrap-toc.js ├── LICENSE-text.html ├── 404.html ├── LICENSE.html ├── authors.html └── pkgdown.css ├── .github ├── .gitignore └── workflows │ └── R-CMD-check.yaml ├── vignettes ├── .gitignore ├── basic_usage.Rmd └── rental_universe.Rmd ├── LICENSE ├── logo.png ├── images ├── buildings.png ├── cityscape.png ├── skyline.png └── cmhc-sticker.png ├── man ├── figures │ └── logo.png ├── list_cmhc_surveys.Rd ├── show_cmhc_cache_path.Rd ├── select_cmhc_table.Rd ├── list_cmhc_series.Rd ├── list_cmhc_tables.Rd ├── cmhc_ct_translation_data.Rd ├── cmhc_cma_translation_data.Rd ├── cmhc_csd_translation_data.Rd ├── list_cmhc_dimensions.Rd ├── cmhc_csd_translation_data_2023.Rd ├── cmhc_quality_labels.Rd ├── list_cmhc_breakdowns.Rd ├── list_cmhc_filters.Rd ├── set_cmhc_cache_path.Rd ├── get_cmhc_geography.Rd └── get_cmhc.Rd ├── pkgdown ├── extra.css ├── favicon │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── apple-touch-icon.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ └── apple-touch-icon-180x180.png └── _pkgdown.yml ├── data ├── cmhc_cma_translation_data.rda ├── cmhc_csd_translation_data.rda ├── cmhc_ct_translation_data.rda └── cmhc_csd_translation_data_2023.rda ├── .gitignore ├── .Rbuildignore ├── cmhc.Rproj ├── NAMESPACE ├── LICENSE.md ├── DESCRIPTION ├── NEWS.md ├── cran-comments.md ├── R ├── helpers.R ├── user_settings.R └── hex_sticker.R └── README.md /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2019 2 | COPYRIGHT HOLDER: Jens von Bergmann 3 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/logo.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/favicon.ico -------------------------------------------------------------------------------- /images/buildings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/images/buildings.png -------------------------------------------------------------------------------- /images/cityscape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/images/cityscape.png -------------------------------------------------------------------------------- /images/skyline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/images/skyline.png -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/man/figures/logo.png -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /images/cmhc-sticker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/images/cmhc-sticker.png -------------------------------------------------------------------------------- /docs/extra.css: -------------------------------------------------------------------------------- 1 | pre, code { 2 | background-color: #f8f8f8; 3 | size: 70%; 4 | color: #333; 5 | } 6 | -------------------------------------------------------------------------------- /pkgdown/extra.css: -------------------------------------------------------------------------------- 1 | pre, code { 2 | background-color: #f8f8f8; 3 | size: 70%; 4 | color: #333; 5 | } 6 | -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /docs/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /docs/reference/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/reference/figures/logo.png -------------------------------------------------------------------------------- /data/cmhc_cma_translation_data.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/data/cmhc_cma_translation_data.rda -------------------------------------------------------------------------------- /data/cmhc_csd_translation_data.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/data/cmhc_csd_translation_data.rda -------------------------------------------------------------------------------- /data/cmhc_ct_translation_data.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/data/cmhc_ct_translation_data.rda -------------------------------------------------------------------------------- /docs/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /data/cmhc_csd_translation_data_2023.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/data/cmhc_csd_translation_data_2023.rda -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /docs/articles/basic_usage_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/basic_usage_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/basic_usage_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/basic_usage_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /docs/articles/basic_usage_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/basic_usage_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /docs/articles/basic_usage_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/basic_usage_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/basic_usage_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/basic_usage_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /docs/articles/rental_universe_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/rental_universe_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /docs/articles/rental_universe_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/rental_universe_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /docs/articles/rental_universe_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mountainMath/cmhc/HEAD/docs/articles/rental_universe_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | inst/doc 6 | data_cache 7 | data_cache/* 8 | helpers/* 9 | helpers 10 | /doc/ 11 | /Meta/ 12 | .DS_Store 13 | CRAN-SUBMISSION 14 | data_raw 15 | data_raw/* 16 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^LICENSE\.md$ 4 | ^helpers 5 | ^docs/ 6 | ^docs/* 7 | ^images/ 8 | ^images/* 9 | ^doc$ 10 | ^Meta$ 11 | ^\.github$ 12 | ^R/hex_sticker.R$ 13 | ^logo.png$ 14 | ^logo.svg$ 15 | ^pkgdown 16 | ^pkgdown/* 17 | ^CRAN-SUBMISSION$ 18 | ^cran-comments\.md$ 19 | ^data_raw/ 20 | ^data_raw/* 21 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: '3.2' 2 | pkgdown: 2.0.9 3 | pkgdown_sha: ~ 4 | articles: 5 | basic_usage: basic_usage.html 6 | rental_universe: rental_universe.html 7 | last_built: 2025-02-04T03:43Z 8 | urls: 9 | reference: https://mountainmath.github.io/cmhc/reference 10 | article: https://mountainmath.github.io/cmhc/articles 11 | 12 | -------------------------------------------------------------------------------- /man/list_cmhc_surveys.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_tables.R 3 | \name{list_cmhc_surveys} 4 | \alias{list_cmhc_surveys} 5 | \title{List available CMHC surveys} 6 | \usage{ 7 | list_cmhc_surveys() 8 | } 9 | \value{ 10 | A data frame with available survey names. 11 | } 12 | \description{ 13 | List available CMHC surveys 14 | } 15 | \examples{ 16 | list_cmhc_surveys() 17 | 18 | } 19 | -------------------------------------------------------------------------------- /man/show_cmhc_cache_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/user_settings.R 3 | \name{show_cmhc_cache_path} 4 | \alias{show_cmhc_cache_path} 5 | \title{View saved cache directory path} 6 | \usage{ 7 | show_cmhc_cache_path() 8 | } 9 | \value{ 10 | a character string with the CMHC cache path 11 | } 12 | \description{ 13 | View saved cache path 14 | } 15 | \examples{ 16 | show_cmhc_cache_path() 17 | 18 | } 19 | -------------------------------------------------------------------------------- /man/select_cmhc_table.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_tables.R 3 | \name{select_cmhc_table} 4 | \alias{select_cmhc_table} 5 | \title{Interactive table selector} 6 | \usage{ 7 | select_cmhc_table() 8 | } 9 | \value{ 10 | A string containing the function call to access the selected table 11 | } 12 | \description{ 13 | Interactive table selector 14 | } 15 | \examples{ 16 | \dontrun{ 17 | select_cmhc_table() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cmhc.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | ProjectId: 674a418d-6b73-49b3-8d21-31196ac37097 3 | 4 | RestoreWorkspace: Default 5 | SaveWorkspace: Default 6 | AlwaysSaveHistory: Default 7 | 8 | EnableCodeIndexing: Yes 9 | UseSpacesForTab: Yes 10 | NumSpacesForTab: 2 11 | Encoding: UTF-8 12 | 13 | RnwWeave: knitr 14 | LaTeX: pdfLaTeX 15 | 16 | AutoAppendNewline: Yes 17 | StripTrailingWhitespace: Yes 18 | 19 | BuildType: Package 20 | PackageUseDevtools: Yes 21 | PackageInstallArgs: --no-multiarch --with-keep.source 22 | -------------------------------------------------------------------------------- /man/list_cmhc_series.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_tables.R 3 | \name{list_cmhc_series} 4 | \alias{list_cmhc_series} 5 | \title{List available CMHC series} 6 | \usage{ 7 | list_cmhc_series(survey = NULL) 8 | } 9 | \arguments{ 10 | \item{survey}{Optional survey to filter by} 11 | } 12 | \value{ 13 | A data frame with survey names, and available series names. 14 | } 15 | \description{ 16 | List available CMHC series 17 | } 18 | \examples{ 19 | list_cmhc_series("Rms") 20 | 21 | } 22 | -------------------------------------------------------------------------------- /man/list_cmhc_tables.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_tables.R 3 | \name{list_cmhc_tables} 4 | \alias{list_cmhc_tables} 5 | \title{List available CMHC tables} 6 | \usage{ 7 | list_cmhc_tables(short = TRUE) 8 | } 9 | \arguments{ 10 | \item{short}{Logical, determines how much detail is returned. Default is `TRUE`.} 11 | } 12 | \value{ 13 | A tibble listing all available CMHC data tables 14 | } 15 | \description{ 16 | List available CMHC tables 17 | } 18 | \examples{ 19 | list_cmhc_tables() 20 | 21 | } 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(cmhc_quality_labels) 4 | export(get_cmhc) 5 | export(get_cmhc_geography) 6 | export(list_cmhc_breakdowns) 7 | export(list_cmhc_dimensions) 8 | export(list_cmhc_filters) 9 | export(list_cmhc_series) 10 | export(list_cmhc_surveys) 11 | export(list_cmhc_tables) 12 | export(select_cmhc_table) 13 | export(set_cmhc_cache_path) 14 | export(show_cmhc_cache_path) 15 | import(dplyr) 16 | importFrom(rlang,.data) 17 | importFrom(rlang,`:=`) 18 | importFrom(stats,na.omit) 19 | importFrom(stats,setNames) 20 | -------------------------------------------------------------------------------- /man/cmhc_ct_translation_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \docType{data} 4 | \name{cmhc_ct_translation_data} 5 | \alias{cmhc_ct_translation_data} 6 | \title{A dataset with geographic identifiers for CMHC and Census at the CT level} 7 | \format{ 8 | A tibble with Census and CMHC geographic identifiers 9 | } 10 | \source{ 11 | Custom data extract from CMHC 12 | } 13 | \description{ 14 | A dataset with geographic identifiers for CMHC and Census at the CT level 15 | } 16 | \author{ 17 | derived from CMHC geographic data 18 | } 19 | \keyword{data} 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/cmhc_cma_translation_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \docType{data} 4 | \name{cmhc_cma_translation_data} 5 | \alias{cmhc_cma_translation_data} 6 | \title{A dataset with geographic identifiers for CMHC and Census at the CMA level} 7 | \format{ 8 | A tibble with Census and CMHC geographic identifiers 9 | } 10 | \source{ 11 | Custom data extract from CMHC 12 | } 13 | \description{ 14 | A dataset with geographic identifiers for CMHC and Census at the CMA level 15 | } 16 | \author{ 17 | derived from CMHC geographic data 18 | } 19 | \keyword{data} 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/cmhc_csd_translation_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \docType{data} 4 | \name{cmhc_csd_translation_data} 5 | \alias{cmhc_csd_translation_data} 6 | \title{A dataset with geographic identifiers for CMHC and Census at the CSD level} 7 | \format{ 8 | A tibble with Census and CMHC geographic identifiers 9 | } 10 | \source{ 11 | Custom data extract from CMHC 12 | } 13 | \description{ 14 | A dataset with geographic identifiers for CMHC and Census at the CSD level 15 | } 16 | \author{ 17 | derived from CMHC geographic data 18 | } 19 | \keyword{data} 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/list_cmhc_dimensions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_tables.R 3 | \name{list_cmhc_dimensions} 4 | \alias{list_cmhc_dimensions} 5 | \title{List available CMHC dimensions} 6 | \usage{ 7 | list_cmhc_dimensions(survey = NULL, series = NULL) 8 | } 9 | \arguments{ 10 | \item{survey}{Optional survey to filter by} 11 | 12 | \item{series}{Optional series to filter by} 13 | } 14 | \value{ 15 | A data frame with survey names, series names, and available dimension names. 16 | } 17 | \description{ 18 | List available CMHC dimensions 19 | } 20 | \examples{ 21 | list_cmhc_dimensions("Rms","Vacancy Rate") 22 | 23 | } 24 | -------------------------------------------------------------------------------- /man/cmhc_csd_translation_data_2023.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \docType{data} 4 | \name{cmhc_csd_translation_data_2023} 5 | \alias{cmhc_csd_translation_data_2023} 6 | \title{A dataset with geographic identifiers for CMHC and Census at the CSD level for 2023 data portal version} 7 | \format{ 8 | A tibble with Census CSD and CMHC METID geographic identifiers 9 | } 10 | \source{ 11 | Custom data extract from CMHC 12 | } 13 | \description{ 14 | A dataset with geographic identifiers for CMHC and Census at the CSD level for 2023 data portal version 15 | } 16 | \author{ 17 | derived from CMHC data 18 | } 19 | \keyword{data} 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/cmhc_quality_labels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/helpers.R 3 | \docType{data} 4 | \name{cmhc_quality_labels} 5 | \alias{cmhc_quality_labels} 6 | \title{A list of CMHC quality indicators} 7 | \format{ 8 | A named vector to translate internal CMHC quality indicators to plain text. 9 | } 10 | \usage{ 11 | cmhc_quality_labels 12 | } 13 | \description{ 14 | Data obtained via this package will automatically translate internal CMHC quality labels 15 | using this translation vector, this named vector is useful when working with CMHC data obtained from other 16 | sources like sporadic excel sheets or data scraped from PDF reports. 17 | } 18 | \keyword{datasets} 19 | -------------------------------------------------------------------------------- /man/list_cmhc_breakdowns.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_tables.R 3 | \name{list_cmhc_breakdowns} 4 | \alias{list_cmhc_breakdowns} 5 | \title{List available CMHC breakdowns} 6 | \usage{ 7 | list_cmhc_breakdowns(survey = NULL, series = NULL, dimension = NULL) 8 | } 9 | \arguments{ 10 | \item{survey}{Optional survey to filter by} 11 | 12 | \item{series}{Optional series to filter by} 13 | 14 | \item{dimension}{Optional dimension to filter by} 15 | } 16 | \value{ 17 | A data frame with survey names, series names, dimension names and available series breakdowns. 18 | } 19 | \description{ 20 | List available CMHC breakdowns 21 | } 22 | \examples{ 23 | list_cmhc_breakdowns("Rms","Vacancy Rate","Bedroom Type") 24 | 25 | } 26 | -------------------------------------------------------------------------------- /man/list_cmhc_filters.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_tables.R 3 | \name{list_cmhc_filters} 4 | \alias{list_cmhc_filters} 5 | \title{List available CMHC filters} 6 | \usage{ 7 | list_cmhc_filters( 8 | survey = NULL, 9 | series = NULL, 10 | dimension = NULL, 11 | breakdown = NULL 12 | ) 13 | } 14 | \arguments{ 15 | \item{survey}{Optional survey to filter by} 16 | 17 | \item{series}{Optional series to filter by} 18 | 19 | \item{dimension}{Optional dimension to filter by} 20 | 21 | \item{breakdown}{Optional breakdown to filter by} 22 | } 23 | \value{ 24 | A data frame with available filters 25 | } 26 | \description{ 27 | List available CMHC filters 28 | } 29 | \examples{ 30 | list_cmhc_filters("Rms","Vacancy Rate","Bedroom Type","Historical Time Periods") 31 | 32 | } 33 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Jens von Bergmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: cmhc 2 | Type: Package 3 | Title: Access, Retrieve, and Work with CMHC Data 4 | Version: 0.2.10 5 | Authors@R: 6 | c(person(given = "Jens", 7 | family = "von Bergmann", 8 | role = c("aut", "cre"), 9 | email = "jens@mountainmath.ca")) 10 | Description: Wrapper around the Canadian Mortgage and Housing Corporation (CMHC) web interface. It enables programmatic and reproducible access to a wide variety of housing data from CMHC. 11 | License: MIT + file LICENSE 12 | Encoding: UTF-8 13 | LazyData: true 14 | ByteCompile: yes 15 | NeedsCompilation: no 16 | Depends: 17 | R (>= 4.1) 18 | Imports: 19 | dplyr (>= 1.0), 20 | digest (>= 0.1), 21 | httr, 22 | readr, 23 | stringr, 24 | tibble, 25 | rlang, 26 | aws.s3 27 | Suggests: 28 | knitr, 29 | scales, 30 | cancensus, 31 | ggplot2, 32 | tidyr, 33 | rmarkdown, 34 | sf 35 | VignetteBuilder: knitr 36 | URL: https://github.com/mountainMath/cmhc, https://mountainmath.github.io/cmhc/, https://www03.cmhc-schl.gc.ca/hmip-pimh/en 37 | BugReports: https://github.com/mountainMath/cmhc/issues 38 | RoxygenNote: 7.3.1 39 | -------------------------------------------------------------------------------- /man/set_cmhc_cache_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/user_settings.R 3 | \name{set_cmhc_cache_path} 4 | \alias{set_cmhc_cache_path} 5 | \title{Set persistent cmhc cache location for geographic data} 6 | \usage{ 7 | set_cmhc_cache_path(cache_path, overwrite = FALSE, install = FALSE) 8 | } 9 | \arguments{ 10 | \item{cache_path}{a local directory to use for saving cached data} 11 | 12 | \item{overwrite}{Option to overwrite any existing cache path already stored locally.} 13 | 14 | \item{install}{Option to install permanently for use across sessions.} 15 | } 16 | \value{ 17 | a character string with the CMHC cache path 18 | } 19 | \description{ 20 | The cmhc package provides access to custom cmhc geographies, these are large files and should be 21 | stored in a permanent location. This function sets the CMHC_CACHE_PATH environment variable and optionally 22 | installs it in the .Renviron file for future use. This is only needed when using the `get_cmhc_geography()` function. 23 | } 24 | \examples{ 25 | \dontrun{ 26 | # This sets the cache path for the duration of the current session 27 | set_cmhc_cache_path("~/cmhc_cache") 28 | 29 | # This will set the cache path permanently until overwritten again 30 | set_cmhc_cache_path("~/cmhc_cache", install = TRUE) 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /pkgdown/_pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.3.1 2 | pkgdown_sha: ~ 3 | 4 | url: https://mountainmath.github.io/cmhc/ 5 | 6 | home: 7 | title: Access, retrieve, and work with CMHC data. 8 | 9 | reference: 10 | - title: Retrieving CMHC data 11 | - contents: 12 | - get_cmhc 13 | - get_cmhc_geography 14 | #- get_census_geometry # deprecated function, removed from online docs 15 | - title: Data discovery 16 | - contents: 17 | - select_cmhc_table 18 | - list_cmhc_tables 19 | - list_cmhc_surveys 20 | - list_cmhc_series 21 | - list_cmhc_dimensions 22 | - list_cmhc_breakdowns 23 | - list_cmhc_filters 24 | - title: Helper functions 25 | - contents: 26 | - cmhc_quality_labels 27 | - title: User settings 28 | - contents: 29 | - set_cmhc_cache_path 30 | - show_cmhc_cache_path 31 | articles: 32 | - title: Basic usage 33 | navbar: ~ 34 | contents: 35 | - basic_usage 36 | - rental_universe 37 | 38 | authors: 39 | Jens von Bergmann: 40 | href: https://mountainmath.ca 41 | template: 42 | params: 43 | #ganalytics: UA-107390160-3 44 | bootswatch: simplex 45 | opengraph: 46 | image: 47 | src: 'https://github.com/mountainMath/cmhc/raw/master/logo.png' 48 | alt: "cmhc" 49 | twitter: 50 | creator: "@vb_jens" 51 | card: summary_large_image 52 | site: "https://mountainmath.github.io/cmhc/" 53 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # cmhc v0.2.0 2 | 3 | * Initial CRAN release, reworked workflows for a simpler way to access CMHC data tables. 4 | 5 | # cmhc v0.2.1 6 | 7 | * rename functions to set and show cache path to avoid conflicts with other packages 8 | * add functionality for additional tables 9 | 10 | # cmhc v0.2.2 11 | 12 | * fix table snafu for Scss by intended market 13 | * add vignette for rental universe 14 | 15 | # cmhc v0.2.3 16 | 17 | * fix more table sanfu for Scss by intended market 18 | * add query builder helper function 19 | * add access to census and core housing need tables 20 | 21 | # cmhc v0.2.4 22 | 23 | * fixes an issue with "Rent Ranges" dimension not properly parsing (Thanks Maxime Bélanger De Blois!) 24 | * add access to secondary market tables 25 | * fix table codes for absorbed units 26 | * improved query builder tool 27 | 28 | # cmhc v0.2.5 29 | 30 | * conditional check of vignettes to account for CMHC server issues 31 | 32 | # cmhc v0.2.6 33 | 34 | * add tables 35 | * adjust to changes with CMHC portal that require MetId to be specified (only partial fix at this point) 36 | * fix link to CMHC terms of use that moved 37 | 38 | ## cmhc v0.2.7 39 | 40 | * add CMHC lookup table for met codes 41 | 42 | ## cmhc v0.2.8 43 | 44 | * expand tables 45 | * improve handling for national level data 46 | * update to new CMHC internal METCODES 47 | 48 | ## cmhc v0.2.9 49 | ### Minor changes 50 | 51 | * adapt to changes to CMHC interface 52 | * intelligent guessing of frequencies for data series retrieval based on temporal arguments supplied 53 | 54 | ## cmhc v0.2.10 55 | ### Minor changes 56 | 57 | * enable data access to more tables 58 | 59 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | branches: [main, master] 6 | pull_request: 7 | branches: [main, master] 8 | schedule: 9 | - cron: "35 15 * * *" 10 | 11 | name: R-CMD-check 12 | 13 | jobs: 14 | R-CMD-check: 15 | runs-on: ${{ matrix.config.os }} 16 | 17 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 18 | 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | config: 23 | - {os: macOS-latest, r: 'release'} 24 | - {os: windows-latest, r: 'release'} 25 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 26 | - {os: ubuntu-latest, r: 'release'} 27 | - {os: ubuntu-latest, r: 'oldrel-1'} 28 | 29 | env: 30 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 31 | CM_API_KEY: ${{ secrets.CM_API_KEY }} 32 | COMPILE_VIG: ${{ secrets.COMPILE_VIG }} 33 | R_KEEP_PKG_SOURCE: yes 34 | 35 | steps: 36 | - uses: actions/checkout@v2 37 | 38 | - uses: r-lib/actions/setup-pandoc@v2 39 | 40 | - uses: r-lib/actions/setup-r@v2 41 | with: 42 | r-version: ${{ matrix.config.r }} 43 | http-user-agent: ${{ matrix.config.http-user-agent }} 44 | use-public-rspm: true 45 | 46 | - uses: r-lib/actions/setup-r-dependencies@v2 47 | with: 48 | extra-packages: any::rcmdcheck 49 | needs: check 50 | 51 | - uses: r-lib/actions/check-r-package@v2 52 | with: 53 | upload-snapshots: true 54 | -------------------------------------------------------------------------------- /man/get_cmhc_geography.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc_geography.R 3 | \name{get_cmhc_geography} 4 | \alias{get_cmhc_geography} 5 | \title{Get CMHC geographies for CMHC Survey Zones and Neighbourhoods} 6 | \usage{ 7 | get_cmhc_geography( 8 | level = c("CT", "ZONE", "NBHD", "CSD", "MET"), 9 | base_directory = Sys.getenv("CMHC_CACHE_PATH") 10 | ) 11 | } 12 | \arguments{ 13 | \item{level}{aggregation level for geographic data, one of "CT","ZONE","NBHD","CSD","MET"} 14 | 15 | \item{base_directory}{local directory to hold CMHC geography data, by default this is inferred from the 16 | CMHC_CACHE_PATH environment variable. To use this function a local data directory has to be set.} 17 | } 18 | \value{ 19 | A spatial data frame with the geographies for the specified geographic level. 20 | } 21 | \description{ 22 | The data can be queried for Census Tracts, Survey Zones, Neighbourhoods, Census Subdivisions and Metropolitan Areas, 23 | but it's most useful for Survey Zones, Neighbourhoods which are particular to CMHC and not available from other sources. 24 | The geographic data corresponds to an extract from 2017, and won't necessarily match regions from other years. The Survey Zones 25 | and Neighbourhoods have been quite stable, but census geographies change over time and can be matched with geographic 26 | data obtained by using the `cancensus` package. 27 | 28 | The geographic data is quite large and a local cache directory needs to be provided. By default the 29 | "CMHC_CACHE_PATH" environment variable is used to determine the cache directory, it can be set via the 30 | `set_cache_path` function. The geographic data will take up about 55Mb of disk space. 31 | } 32 | \examples{ 33 | \dontrun{ 34 | get_cmhc_geography("ZONE") 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## cmhc v0.2.10 2 | ### Minor changes 3 | 4 | * enable data access to more tables 5 | 6 | ## cmhc v0.2.9 7 | ### Minor changes 8 | 9 | * adapt to changes to CMHC interface 10 | * intelligent guessing of frequencies for data series retrieval based on temporal arguments supplied 11 | 12 | ## cmhc v0.2.8 13 | ### Minor changes 14 | 15 | * expand tables 16 | * improve handling for national level data 17 | * update to new CMHC internal METCODES 18 | 19 | ## cmhc v0.2.7 20 | ### Minor changes 21 | 22 | * add CMHC lookup table for met codes 23 | 24 | 25 | ## cmhc v0.2.6 26 | ### Minor changes 27 | 28 | * add tables 29 | * adjust to changes with CMHC portal that require MetId to be specified (only partial fix at this point) 30 | * fix link to CMHC terms of use that moved 31 | 32 | ## cmhc v0.2.5 33 | ### Minor changes 34 | 35 | * conditional check of vignettes to account for CMHC server issues 36 | 37 | ## cmhc v0.2.4 38 | ### Minor changes 39 | 40 | * fixes an issue with "Rent Ranges" dimension not properly parsing 41 | * add access to secondary market tables 42 | * fix table codes for absorbed units 43 | * improved query builder tool 44 | 45 | ## cmhc v0.2.3 46 | ### Minor changes 47 | 48 | * fix more table snafu for Scss by intended market 49 | * add query builder helper function 50 | * add access to census and core housing need tables 51 | 52 | ## cmhc v0.2.2 53 | ### Minor changes 54 | 55 | * fix table sanfu for Scss by intended market 56 | * add vignette for rental universe 57 | 58 | ## cmhc v0.2.1 59 | ### Minor changes 60 | 61 | * add functionality for additional tables 62 | * rename functions to set and show cache path to avoid conflicts with other packages 63 | 64 | ## cmhc v0.2.0 65 | 66 | * This is a new release. 67 | Local checks on R version 4.2 68 | Standard GitHub action checks on macOS-latest, windows-lastest, ubuntu-latest (release, devel, oldrel-1) 69 | 0 errors | 0 warnings | 0 notes 70 | 71 | * Cleaned up the Rd files for better and more consistent documentation. 72 | * Clarified that by default data is only downloaded to tempdir(), if spatial data is also needed a local cache path 73 | needs to be set explicitly in order to download and cache the data permanenetly. 74 | * Adding a link to the data source in angled brackets in the description field of the DESCRIPTION file by appending triggered a note in the automatic CRAN checks "Malformed Description field: should contain one or more complete sentences.", possibly due to the addition of the URL messing up the parsing of the field. Instead of adding the link to the description field I have added it to the URL section. 75 | 76 | -------------------------------------------------------------------------------- /R/helpers.R: -------------------------------------------------------------------------------- 1 | #' Convert CMHC month and date field to Date 2 | #' 3 | #' @param X1 month and date field as returned by CMHC 4 | #' @noRd 5 | #' @return a vector of dates 6 | date_from_cmhc_year_month <- function(X1){ 7 | as.Date(paste0("01 ",X1),format="%d %b %Y") 8 | } 9 | 10 | 11 | #' A list of CMHC quality indicators 12 | #' 13 | #' @description Data obtained via this package will automatically translate internal CMHC quality labels 14 | #' using this translation vector, this named vector is useful when working with CMHC data obtained from other 15 | #' sources like sporadic excel sheets or data scraped from PDF reports. 16 | #' 17 | #' @format A named vector to translate internal CMHC quality indicators to plain text. 18 | #' @export 19 | cmhc_quality_labels <- c(a = "Excellent", b = "Very good", c = "Good", d = "Fair (Use with Caution)") 20 | 21 | 22 | #' parse numeric values 23 | #' @param x character vector to convert to mumeric 24 | #' @noRd 25 | #' @return a vector of numeric values 26 | parse_numeric <- function(x){ 27 | xx<-x %>% 28 | gsub(",", "", ., fixed = TRUE) %>% 29 | gsub(" %","",.,fixed = TRUE) 30 | xx[xx=="-"]="0" 31 | xx[xx=="++"]=NA_character_ 32 | xx[xx=="n/a"]=NA_character_ 33 | xx[xx=="**"]=NA_character_ 34 | as.numeric(xx) 35 | } 36 | 37 | 38 | get_cmhc_cma_translation_data <- function() { 39 | cmhc::cmhc_cma_translation_data # %>% 40 | #mutate(METCODE=ifelse(.data$CMA_UID=="59938","1100",.data$METCODE)) 41 | } 42 | 43 | 44 | #' A dataset with geographic identifiers for CMHC and Census at the CMA level 45 | #' @name cmhc_cma_translation_data 46 | #' @docType data 47 | #' @author derived from CMHC geographic data 48 | #' @source Custom data extract from CMHC 49 | #' @format A tibble with Census and CMHC geographic identifiers 50 | #' @keywords data internal 51 | NULL 52 | 53 | #' A dataset with geographic identifiers for CMHC and Census at the CSD level 54 | #' @name cmhc_csd_translation_data 55 | #' @docType data 56 | #' @author derived from CMHC geographic data 57 | #' @source Custom data extract from CMHC 58 | #' @format A tibble with Census and CMHC geographic identifiers 59 | #' @keywords data internal 60 | NULL 61 | 62 | #' A dataset with geographic identifiers for CMHC and Census at the CSD level for 2023 data portal version 63 | #' @name cmhc_csd_translation_data_2023 64 | #' @docType data 65 | #' @author derived from CMHC data 66 | #' @source Custom data extract from CMHC 67 | #' @format A tibble with Census CSD and CMHC METID geographic identifiers 68 | #' @keywords data internal 69 | NULL 70 | 71 | #' A dataset with geographic identifiers for CMHC and Census at the CT level 72 | #' @name cmhc_ct_translation_data 73 | #' @docType data 74 | #' @author derived from CMHC geographic data 75 | #' @source Custom data extract from CMHC 76 | #' @format A tibble with Census and CMHC geographic identifiers 77 | #' @keywords data internal 78 | NULL 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | https://mountainmath.github.io/cmhc/404.html 5 | 6 | 7 | https://mountainmath.github.io/cmhc/LICENSE-text.html 8 | 9 | 10 | https://mountainmath.github.io/cmhc/LICENSE.html 11 | 12 | 13 | https://mountainmath.github.io/cmhc/articles/basic_usage.html 14 | 15 | 16 | https://mountainmath.github.io/cmhc/articles/index.html 17 | 18 | 19 | https://mountainmath.github.io/cmhc/articles/rental_universe.html 20 | 21 | 22 | https://mountainmath.github.io/cmhc/authors.html 23 | 24 | 25 | https://mountainmath.github.io/cmhc/index.html 26 | 27 | 28 | https://mountainmath.github.io/cmhc/news/index.html 29 | 30 | 31 | https://mountainmath.github.io/cmhc/reference/cmhc_cma_translation_data.html 32 | 33 | 34 | https://mountainmath.github.io/cmhc/reference/cmhc_csd_translation_data.html 35 | 36 | 37 | https://mountainmath.github.io/cmhc/reference/cmhc_csd_translation_data_2023.html 38 | 39 | 40 | https://mountainmath.github.io/cmhc/reference/cmhc_ct_translation_data.html 41 | 42 | 43 | https://mountainmath.github.io/cmhc/reference/cmhc_quality_labels.html 44 | 45 | 46 | https://mountainmath.github.io/cmhc/reference/get_cmhc.html 47 | 48 | 49 | https://mountainmath.github.io/cmhc/reference/get_cmhc_geography.html 50 | 51 | 52 | https://mountainmath.github.io/cmhc/reference/index.html 53 | 54 | 55 | https://mountainmath.github.io/cmhc/reference/list_cmhc_breakdowns.html 56 | 57 | 58 | https://mountainmath.github.io/cmhc/reference/list_cmhc_dimensions.html 59 | 60 | 61 | https://mountainmath.github.io/cmhc/reference/list_cmhc_filters.html 62 | 63 | 64 | https://mountainmath.github.io/cmhc/reference/list_cmhc_series.html 65 | 66 | 67 | https://mountainmath.github.io/cmhc/reference/list_cmhc_surveys.html 68 | 69 | 70 | https://mountainmath.github.io/cmhc/reference/list_cmhc_tables.html 71 | 72 | 73 | https://mountainmath.github.io/cmhc/reference/select_cmhc_table.html 74 | 75 | 76 | https://mountainmath.github.io/cmhc/reference/set_cmhc_cache_path.html 77 | 78 | 79 | https://mountainmath.github.io/cmhc/reference/show_cmhc_cache_path.html 80 | 81 | 82 | -------------------------------------------------------------------------------- /R/user_settings.R: -------------------------------------------------------------------------------- 1 | # Functions for managing user settings, cache locations 2 | 3 | 4 | #' Set persistent cmhc cache location for geographic data 5 | #' 6 | #' @description The cmhc package provides access to custom cmhc geographies, these are large files and should be 7 | #' stored in a permanent location. This function sets the CMHC_CACHE_PATH environment variable and optionally 8 | #' installs it in the .Renviron file for future use. This is only needed when using the `get_cmhc_geography()` function. 9 | #' 10 | #' @param cache_path a local directory to use for saving cached data 11 | #' @param overwrite Option to overwrite any existing cache path already stored locally. 12 | #' @param install Option to install permanently for use across sessions. 13 | #' 14 | #' @return a character string with the CMHC cache path 15 | #' @examples 16 | #'\dontrun{ 17 | #' # This sets the cache path for the duration of the current session 18 | #' set_cmhc_cache_path("~/cmhc_cache") 19 | #' 20 | #' # This will set the cache path permanently until overwritten again 21 | #' set_cmhc_cache_path("~/cmhc_cache", install = TRUE) 22 | #' } 23 | #' 24 | #' @export 25 | set_cmhc_cache_path <- function(cache_path, overwrite = FALSE, install = FALSE){ 26 | if (install) { 27 | home <- Sys.getenv("HOME") 28 | renv <- file.path(home, ".Renviron") 29 | if(!file.exists(renv)){ 30 | file.create(renv) 31 | } else{ 32 | # Backup original .Renviron before doing anything else here. 33 | file.copy(renv, file.path(home, ".Renviron_backup")) 34 | if(isTRUE(overwrite)){ 35 | message("Your original .Renviron will be backed up and stored in your R HOME directory if needed.") 36 | oldenv=readLines(renv) 37 | newenv <- oldenv[-grep("CMHC_CACHE_PATH", oldenv)] 38 | writeLines(newenv, renv, sep = "\n") 39 | } else{ 40 | tv <- readLines(renv) 41 | if(any(grepl("CMHC_CACHE_PATH",tv))){ 42 | stop("A saved cache already exists. You can overwrite it with the argument overwrite=TRUE", call.=FALSE) 43 | } 44 | } 45 | } 46 | 47 | keyconcat <- paste0("CMHC_CACHE_PATH='", cache_path, "'") 48 | # Append cache path .Renviron file 49 | write(keyconcat, renv, sep = "\n", append = TRUE) 50 | Sys.setenv('CMHC_CACHE_PATH' = cache_path) 51 | message('Your cache path has been stored in your .Renviron and can be accessed by Sys.getenv("CMHC_CACHE_PATH").') 52 | } else { 53 | message("Cache set for duration of session. To permanently add your cache path for use across sessions, run this function with `install = TRUE`.") 54 | Sys.setenv('CMHC_CACHE_PATH' = cache_path) 55 | } 56 | cache_path 57 | } 58 | 59 | #' View saved cache directory path 60 | #' 61 | #' @description View saved cache path 62 | #' 63 | #' @return a character string with the CMHC cache path 64 | #' @examples 65 | #' show_cmhc_cache_path() 66 | #' 67 | #' @export 68 | show_cmhc_cache_path <- function() { 69 | Sys.getenv('CMHC_CACHE_PATH') 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /man/get_cmhc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cmhc.R 3 | \name{get_cmhc} 4 | \alias{get_cmhc} 5 | \title{Access CMHC data via the HMIP.} 6 | \usage{ 7 | get_cmhc( 8 | survey, 9 | series, 10 | dimension, 11 | breakdown, 12 | geoFilter = "Default", 13 | geo_uid, 14 | year = NULL, 15 | quarter = NULL, 16 | month = NULL, 17 | frequency = NULL, 18 | filters = list(), 19 | refresh = FALSE 20 | ) 21 | } 22 | \arguments{ 23 | \item{survey}{The CMHC survey, one of "Scss", "Rms", "Srms", and "Seniors", consult `list_cmhc_surveys()` for possible values. 24 | (Other surveys and more data series may be supported in future versions.)} 25 | 26 | \item{series}{The CMHC data series of the survey, consult `list_cmhc_series()` for possible values.} 27 | 28 | \item{dimension}{The dimension to show in the results, consult `list_cmhc_dimensions()` for possible values.} 29 | 30 | \item{breakdown}{The geographic breakdown, one of "Survey Zones", "Census Subdivision", "Neighbourhoods", "Census Tracts", 31 | if querying data for a snapshot in time or "Historical Time Periods" if querying time series data. Not all geographic breakdowns are available for all series. 32 | returns data frame with CMHC data, tile and subtitle are set as attributes. Consult `list_cmhc_breakdowns()` for possible values.} 33 | 34 | \item{geoFilter}{optional geographic type, only relevaent for provincial and Canada-wide tables. Options are "Default" (the default) 35 | which considers accesses the default tables which should be used for data at the metro area or finer geographies. The other designaters 36 | are only useful when used in conjunction with `geo_uid`s for provinces or all of Canada. Specifying "All" will 37 | give data for all sub-regions, "Metro", which only considers data in metro areas, "50k" and "10k", which only considers data from metro areas and agglomerations with at least 38 | 50k or 10k people, respectively.} 39 | 40 | \item{geo_uid}{Census geographic identifier for which to query the data. Can be a census tract, census subdivision, 41 | or census metropolitan area.} 42 | 43 | \item{year}{optional, only needed when querying data for a snapshot in time.} 44 | 45 | \item{quarter}{optional, only needed when querying data for a snapshot in time querying quarterly data.} 46 | 47 | \item{month}{optional, only needed when querying data for a snapshot in time.} 48 | 49 | \item{frequency}{optional, only needed when querying time series data, one of "Monthly", "Quarterly" or "Annual".} 50 | 51 | \item{filters}{optional list of filters, consult `list_cmhc_filters()` for possible values.} 52 | 53 | \item{refresh}{optional, refresh the temporary local cache of the CMHC tables. Defaults to `FALSE`.} 54 | } 55 | \value{ 56 | A tibble with the data in long form. 57 | } 58 | \description{ 59 | The data access needs to specify the survey, series, dimension (if any), and breakdown to specify the 60 | CMHC table to pull the data from. The `list_cmhc_tables()` function can be used to list all the tables available 61 | via this package. Snapshot data needs to specify the year, or if it is monthly data the month. Time series data, i.e. 62 | when `breakdown="Historical Time Series` is specified, does not need year or month parameters, but may have the 63 | frequency parameter set. Filters provide additional ways to filter the tables by sub-categories. 64 | } 65 | \examples{ 66 | \dontrun{ 67 | data <- get_cmhc("Rms","Vacancy Rate","Bedroom Type","Historical Time Periods","5915022") 68 | } 69 | } 70 | \keyword{API} 71 | \keyword{CMHC} 72 | \keyword{Canada} 73 | \keyword{data} 74 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $("div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cmhc 2 | 3 | 4 | [![R-CMD-check](https://github.com/mountainMath/cmhc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mountainMath/cmhc/actions/workflows/R-CMD-check.yaml) 5 | [![CRAN status](https://www.r-pkg.org/badges/version/cmhc)](https://CRAN.R-project.org/package=cmhc) 6 | [![CRAN_Downloads_Badge](https://cranlogs.r-pkg.org/badges/cmhc)](https://cranlogs.r-pkg.org/badges/cmhc) 7 | 8 | 9 | 10 | 11 | 12 | API wrapper for extracting CMHC data out of the [CMHC Housing Market Information Portal](https://www.cmhc-schl.gc.ca/hmiportal). 13 | 14 | 15 | 16 | ## Reference 17 | Documentation is [available on the GitHub pages](https://mountainmath.github.io/cmhc/). 18 | 19 | The example vignettes contain some [common use cases](https://mountainmath.github.io/cmhc/articles/basic_usage.html). 20 | 21 | ## Installation 22 | The stable version of **cmhc** can be easily installed from CRAN. 23 | ``` 24 | install.packages("cmhc") 25 | ``` 26 | 27 | Alternatively, the latest development version can be installed from Github. 28 | ``` 29 | remotes::install_github("mountainmath/cmhc") 30 | ``` 31 | 32 | ## Usage 33 | Consult the example vignette for more information. As an example, this is how to extract time series information 34 | for vacancy rate data by bedroom type for the Vancouver Census Metropolitan Area ("59933"). 35 | 36 | ``` 37 | library(cmhc) 38 | vacancy_data <- get_cmhc(survey="Rms",series="Vacancy Rate",dimension="Bedroom Type", 39 | breakdown="Historical Time Periods", geo_uid="59933") 40 | 41 | ``` 42 | 43 | Starting with version v.0.3.2 the package has an interactive query builder helper function `select_cmhc_table()` that interactively walks through the available data and builds parameters for `get_cmhc()` like the example above. This makes it easy to discover data and build function calls to CMHC tables. 44 | 45 | ## Contributing 46 | 47 | * We encourage contributions to improve this project. The best way is through issues and pull requests. 48 | * If you want to get in touch, we are pretty good at responding via email or via twitter at [@vb_jens](https://twitter.com/vb_jens). 49 | 50 | ## Cite **cmhc** 51 | 52 | If you wish to cite cmhc: 53 | 54 | von Bergmann, J. (2025) cmhc: R package to access, retrieve, and work with CMHC data. v0.2.10. DOI: 10.32614/CRAN.package.cmhc 55 | 56 | 57 | A BibTeX entry for LaTeX users is 58 | ``` 59 | @Manual{cmhc, 60 | author = {Jens {von Bergmann}}, 61 | title = {cmhc: R package to access, retrieve, and work with CMHC data}, 62 | year = {2025}, 63 | doi = {10.32614/CRAN.package.cmhc}, 64 | note = {R package version 0.2.10}, 65 | url = {https://mountainmath.github.io/cmhc/}, 66 | } 67 | ``` 68 | 69 | ## Related packages 70 | 71 | The cmhc package is designed to work well with the [**cancensus** package](https://mountainmath.github.io/cancensus/) working with Canadian Census data the [**cansim** package](https://mountainmath.github.io/cansim/) for regular StatCan tables, and matches the census geographies via a `GeoUID` column that is shared across these packages. The [**tongfen** package](https://mountainmath.github.io/tongfen/) facilitates making geographies from different census years that CMHC reports on comparable over time. 72 | 73 | ## CMHC Attribution 74 | 75 | Subject to the [CMHC Data License Agreement](https://www.cmhc-schl.gc.ca/about-us/terms-conditions/hmip-terms-conditions), licensed products using CMHC data should employ the following acknowledgement of source: 76 | 77 | 78 | ### Acknowledgment of Source 79 | 80 | a. You shall include the following notice on all reproductions of the Information: 81 | 82 | > Source: Canada Mortgage and Housing Corporation (CMHC), name of product or information, reference date. This information is reproduced and distributed on an “as is” basis with the permission of CMHC. 83 | 84 | b. Where any Information is contained within a Value-added Product, you shall include on such Value-added Product the following notice: 85 | 86 | > Adapted from Canada Mortgage and Housing Corporation, name of product or information, reference date. This does not constitute an endorsement by Canada Mortgage and Housing Corporation of this product. 87 | or any other notice approved in advance in writing by CMHC. 88 | 89 | 90 | -------------------------------------------------------------------------------- /R/hex_sticker.R: -------------------------------------------------------------------------------- 1 | #' Internal function to generate hex sticker 2 | #' @keywords internal 3 | generate_cmhc_hex_sticker <- function (){ 4 | library(tidyverse) 5 | library(cmhc) 6 | ggplot2::theme_set(ggplot2::theme_gray()) 7 | inflation <- cansim::get_cansim_vector("v41690973") |> 8 | select(Date,CPI=val_norm) |> 9 | mutate(CPIchange=CPI/lag(CPI,order_by = Date,n=12)-1) 10 | 11 | pd1 <- get_cmhc("Rms","Vacancy Rate","Bedroom Type","Historical Time Periods","48825") |> 12 | bind_rows(get_cmhc("Rms","Vacancy Rate","Bedroom Type","Historical Time Periods","48825",filter=list("season"="April"))) |> 13 | mutate(Value=Value/100) 14 | pd2 <- get_cmhc("Rms","Average Rent Change","Bedroom Type","Historical Time Periods","48825") |> 15 | bind_rows(get_cmhc("Rms","Average Rent Change","Bedroom Type","Historical Time Periods","48825",filter=list("season"="April"))) |> 16 | mutate(Value=Value/100) |> 17 | left_join(inflation,by="Date") |> 18 | mutate(Value=Value-CPIchange) 19 | 20 | pd <- bind_rows(pd1,pd2) |> 21 | filter(`Bedroom Type`=="Total") %>% 22 | left_join(filter(.,!is.na(Value)) |> 23 | select(Series,Date) |> 24 | group_by(Series) |> 25 | mutate(diff=as.integer(Date-lag(Date,order_by=Date))), 26 | by=c("Date","Series")) |> 27 | group_by(Series) |> 28 | filter(!is.na(Value) | (!is.na(lead(diff,order_by = Date)) & lead(diff,order_by = Date)>366)) 29 | 30 | 31 | read_white_image <- function(path){ 32 | logo<-magick::image_read(path) 33 | img <- logo[[1]] 34 | img[1,,] <- as.raw(205) 35 | img[2,,] <- as.raw(133) 36 | img[3,,] <- as.raw(63) 37 | magick::image_read(img) 38 | } 39 | 40 | library(grid) 41 | i1 <- read_white_image(here::here("images/cityscape.png")) |> rasterGrob(interpolate=TRUE) 42 | i2 <- read_white_image(here::here("images/buildings.png")) |> rasterGrob(interpolate=TRUE) 43 | i3 <- read_white_image(here::here("images/skyline.png")) |> rasterGrob(interpolate=TRUE) 44 | 45 | crs <- "+proj=lcc +lat_1=50 +lat_2=70 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m no_defs" 46 | 47 | ca_data <- cancensus::get_census("CA21",regions=list(C="01"),geo_format='sf') %>% 48 | sf::st_transform(crs) 49 | cities <- cancensus::get_census("CA21",regions=list(CMA=c("59933","47705","35535")),geo_format='sf') |> 50 | arrange(Population) |> 51 | sf::st_transform(crs) |> 52 | select() |> 53 | sf::st_centroid() |> 54 | sf::st_coordinates() |> 55 | as_tibble() 56 | q <- ggplot2::ggplot(ca_data) + 57 | ggplot2::geom_sf(fill="#800000",size=0.01) + 58 | ggplot2::theme_void() + 59 | hexSticker::theme_transparent() 60 | bbox=sf::st_bbox(ca_data) 61 | p<-ggplot2::ggplot(pd %>% filter(!is.na(Value)),ggplot2::aes(x=Date,y=Value,color=Series)) + 62 | ggplot2::geom_point(aes(shape=Quality),size=0.8) + 63 | ggplot2::geom_line(size=0.3) + 64 | #ggplot2::scale_colour_brewer(palette="Dark2",guide="none") + 65 | ggplot2::scale_color_manual(values=c("Average Rent Change"="#f0c60a", 66 | "Vacancy Rate"="#f0430a"), 67 | guide="none") + 68 | ggplot2::scale_shape_discrete(guide="none") + 69 | ggplot2::labs(x="",y="") + 70 | ggplot2::theme_void() + 71 | hexSticker::theme_transparent() 72 | 73 | xmin <- as.numeric(bbox$xmin) 74 | xwidth <- as.numeric(bbox$xmax-bbox$xmin) 75 | ymin <- as.numeric(bbox$ymin) 76 | ywidth <- as.numeric(bbox$ymax-bbox$ymin) 77 | 78 | size=0.1 79 | 80 | pp <- q + 81 | ggplot2::annotation_custom(i3, xmin=cities$X[1]-size*xwidth,xmax=cities$X[1]+size*xwidth, 82 | ymin=cities$Y[1],ymax=cities$Y[1]+2*size*ywidth) + 83 | ggplot2::annotation_custom(i1, xmin=cities$X[2]-size*xwidth,xmax=cities$X[2]+size*xwidth, 84 | ymin=cities$Y[2],ymax=cities$Y[2]+2*size*ywidth) + 85 | ggplot2::annotation_custom(i2, xmin=cities$X[3]-size*xwidth,xmax=cities$X[3]+size*xwidth, 86 | ymin=cities$Y[3],ymax=cities$Y[3]+2*size*ywidth) + 87 | ggplot2::annotation_custom(ggplot2::ggplotGrob(p), 88 | xmin=1.5*bbox$xmin,xmax=1.5*bbox$xmax, 89 | ymin=bbox$ymin*0.8+bbox$ymax*0.2,ymax=bbox$ymax*1.1) + 90 | hexSticker::theme_transparent() 91 | 92 | hexSticker::sticker(pp, package="cmhc", 93 | p_size=12, p_y=1.5, 94 | s_x=1, s_y=0.78, s_width=1.5, s_height=1.5, 95 | h_color="#FF0000", 96 | h_fill="grey40", 97 | p_color="white", 98 | filename=here::here("logo.svg")) 99 | 100 | hexSticker::sticker(pp, package="cmhc", 101 | p_size=22, p_y=1.65, 102 | s_x=1, s_y=0.78, s_width=1.5, s_height=1.5, 103 | h_color="#FF0000", 104 | h_fill="grey40", 105 | p_color="white", 106 | filename=here::here("logo.png")) 107 | 108 | } 109 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | License • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 61 | 62 |
    YEAR: 2019
    63 | COPYRIGHT HOLDER: Jens von Bergmann
    64 | 
    65 | 66 |
    67 | 68 | 71 | 72 |
    73 | 74 | 75 | 76 |
    85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | Articles • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 61 | 62 |
    63 |

    Basic usage

    64 |

    65 | 66 |
    Basic usage
    67 |
    68 |
    Rental Universe
    69 |
    70 |
    71 |
    72 |
    73 | 74 | 75 |
    84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /vignettes/basic_usage.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Basic usage" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{Basic usage} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>", 14 | eval = nzchar(Sys.getenv("COMPILE_VIG")) 15 | ) 16 | ``` 17 | 18 | ```{r setup, message=FALSE, warning=FALSE} 19 | library(cmhc) 20 | library(dplyr) 21 | library(ggplot2) 22 | ``` 23 | 24 | To list the CMHC tables available via the package we can call `list_cmhc_tables`. 25 | ```{r} 26 | list_cmhc_tables() |> 27 | head() |> 28 | knitr::kable() 29 | ``` 30 | 31 | It lists all possible tables by survey, series, dimension and breakdown, as well as the possible filters that can be applied. It is often convenient to run the `select_cmhc_table()` interactive query builder in the console to iteratively walk through building the parameters for the `get_cmhc()` data query. 32 | 33 | To access a time series for a region with census geographic identifier `geo_uid` we use `breakdown="Historical Time Periods"`. 34 | 35 | ```{r} 36 | vacancy_data <- get_cmhc(survey="Rms",series="Vacancy Rate",dimension="Bedroom Type", 37 | breakdown="Historical Time Periods", geo_uid="3506008") 38 | 39 | ggplot(vacancy_data,aes(x=Date,y=Value/100,colour=`Bedroom Type`)) + 40 | geom_point(aes(shape=Quality), data=~filter(.,!is.na(Value))) + 41 | geom_line() + 42 | scale_y_continuous(labels=scales::percent) + 43 | labs(title="City of Ottawa rental vacancy rate", 44 | x=NULL, y="Rental vacancy rate", 45 | caption="CMHC Rms") 46 | ``` 47 | 48 | By default this fetches the data for the October survey only, in the past the Rental Market Survey was conducted twice a year. We can pass a filter option to access the April data and fold that in. We can explore the possible filter values could be used for this series via the `list_cmhc_filters` convenience function. 49 | 50 | ```{r} 51 | list_cmhc_filters("Rms","Vacancy Rate","Bedroom Type","Historical Time Periods")$Filters 52 | ``` 53 | 54 | This tells us we could filter by dwelling type, with "Row" or "Apartment" as possible values, and by season, with "April" or "October" as possible values. We want the get April values to add to our existing data. 55 | 56 | ```{r} 57 | vacancy_data2 <- get_cmhc(survey="Rms",series="Vacancy Rate",dimension="Bedroom Type", 58 | breakdown="Historical Time Periods", geo_uid="3506008",filters = list("season"="April")) 59 | 60 | bind_rows(vacancy_data,vacancy_data2) |> 61 | filter(!is.na(Value)) |> 62 | ggplot(aes(x=Date,y=Value/100,colour=`Bedroom Type`)) + 63 | geom_point(aes(shape=Quality), data=~filter(.,!is.na(Value))) + 64 | geom_line() + 65 | scale_y_continuous(labels=scales::percent) + 66 | labs(title="City of Ottawa rental vacancy rate", 67 | x=NULL, y="Rental vacancy rate", 68 | caption="CMHC Rms") 69 | ``` 70 | 71 | Vacancy Rate shows the number of units that are vacant and not rented out at the time. A related metric is the Availability Rate, which measures if a unit is available for rent, including units where a tenant has given notice but has not moved out yet. 72 | 73 | ```{r} 74 | availability_rate <- c("April","October") |> 75 | lapply(function(season) 76 | get_cmhc(survey="Rms",series="Availability Rate",dimension="Bedroom Type", 77 | breakdown="Historical Time Periods", geo_uid="3506008",filters = list("season"=season))) |> 78 | bind_rows() 79 | 80 | availability_rate |> 81 | filter(!is.na(Value)) |> 82 | ggplot(aes(x=Date,y=Value/100,colour=`Bedroom Type`)) + 83 | geom_point(aes(shape=Quality), data=~filter(.,!is.na(Value))) + 84 | geom_line() + 85 | scale_y_continuous(labels=scales::percent) + 86 | labs(title="City of Ottawa rental availability rate", 87 | x=NULL, y="Rental availability rate", 88 | caption="CMHC Rms") 89 | ``` 90 | 91 | As expected, the availability rate is higher than the vacancy rate, unfortunately the collection of availability rates was discontinued. Another related metrics is the turnover rate, but unfortunately this data is not published in the HMIP. 92 | 93 | For data that is collected on a monthly basis, like the Survey of Starts and Completions (Scss) data, we can specify the frequency and also get annual or quarterly data. That makes things more efficient if we are just interested in annual data. 94 | 95 | ```{r} 96 | completions_data <- get_cmhc(survey="Scss",series="Completions",dimension="Dwelling Type", 97 | breakdown="Historical Time Periods", geo_uid="5915022", 98 | frequency = "Annual") 99 | 100 | ggplot(completions_data,aes(x=Date,y=Value,fill=`Dwelling Type`)) + 101 | geom_bar(stat="identity") + 102 | facet_wrap(~`Dwelling Type`,scales="free_y") + 103 | scale_fill_discrete(guide="none") + 104 | scale_y_continuous(labels=scales::comma) + 105 | labs(title="City of Vancouver housing completions", 106 | x=NULL, y="Annual completions", 107 | caption="CMHC Scss") 108 | ``` 109 | 110 | To get snapshot data for sub-geographies, we can select the breakdown geography type. This can be linked back with census geographies for plotting. 111 | 112 | ```{r} 113 | under_construction_data <- get_cmhc(survey="Scss",series="Under Construction",dimension="Dwelling Type", 114 | breakdown="Census Tracts", geo_uid="5915022", 115 | year = 2022, month = 4) 116 | 117 | geo_data <- cancensus::get_census("CA16",regions=list(CSD="5915022"),geo_format = 'sf', level="CT", quiet=TRUE) 118 | 119 | geo_data |> 120 | left_join(under_construction_data |> 121 | filter(`Dwelling Type`=="All"), 122 | by="GeoUID") |> 123 | mutate(value=cut(coalesce(Value,0), 124 | breaks=c(-Inf,0,10,50,100,500,1000,1500,Inf), 125 | labels=c("0","1 to 10","11 to 50","51 to 100","101 to 500", 126 | "501 to 1000","1001 to 1500","Over 1500"))) |> 127 | ggplot(aes(fill=value)) + 128 | geom_sf() + 129 | scale_fill_viridis_d() + 130 | coord_sf(datum=NA) + 131 | labs(title="City of Vancouver housing units under construction April 2022", 132 | fill="Number of units", 133 | caption="CMCH Scss") 134 | ``` 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /vignettes/rental_universe.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Rental Universe" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{Rental Universe} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set( 12 | collapse = TRUE, 13 | comment = "#>", 14 | eval = nzchar(Sys.getenv("COMPILE_VIG")) 15 | ) 16 | ``` 17 | 18 | ```{r setup} 19 | library(cmhc) 20 | library(ggplot2) 21 | library(dplyr) 22 | ``` 23 | 24 | To understand how many purpose built rental units got constructed and torn down in each Metro Vancouver municipality query the rental universe for Metro Vancouver census subdivisions by period of construction for all years from 1990 to 2021. 25 | 26 | ```{r} 27 | rental_data <- seq(1990,2021) |> 28 | lapply(function(y)get_cmhc("Rms","Rental Universe","Year of Construction","Census Subdivision", 29 | geo_uid="59933",year=y)) %>% 30 | bind_rows() 31 | ``` 32 | 33 | Computing year over year differences we can see how the stock has changed in the top municipalities. Over this time period the municipal status of some of the municipalities changed and we make the necessary adjustments. If we assume that periods did not get torn down in the same age bracked as they got built we can interpret this as gross flows. 34 | 35 | Sometimes units move in and out of the universe because of extensive renovations, and it will appear that we add old buildings. Another way how we have added old buildings to the rental universe is hotel conversions. So our proxy of using period of construction is not perfect, but ballpark estimates are about right. 36 | 37 | ```{r} 38 | rental_data %>% 39 | filter(!is.na(`Census Subdivision`)) %>% 40 | mutate(Name=gsub("\\(C\\)","(CY)",`Census Subdivision`)) %>% 41 | mutate(Name=recode(Name, 42 | "Burnaby (DM)"="Burnaby (CY)", 43 | "Coquitlam (DM)"="Coquitlam (CY)", 44 | "Surrey (DM)"="Surrey (CY)")) %>% 45 | filter(Name %in% (filter(.,`Year of Construction`=="Total",Date==max(Date)) %>% 46 | slice_max(Value,n=6) %>% 47 | pull(Name))) %>% 48 | filter(`Year of Construction`!="Total") %>% 49 | group_by(Name,`Year of Construction`) %>% 50 | mutate(Change=Value-lag(Value,order_by = Date)) %>% 51 | mutate(`Year of Construction`=factor(`Year of Construction`,levels=rev(levels(`Year of Construction`)))) %>% 52 | ungroup() %>% 53 | filter(Date!=min(Date)) %>% 54 | ggplot(aes(x=Date,y=Change,fill=`Year of Construction`)) + 55 | geom_bar(stat="identity") + 56 | facet_wrap(~Name,scales="free_y") + 57 | theme(legend.position = "bottom") + 58 | labs(title="Year over year change in rental stock", 59 | y="Number of units", 60 | x=NULL, 61 | fill="Period of construction", 62 | caption="CMHC Rms") 63 | ``` 64 | 65 | We can also look at the total change over this timeframe to understand gross flows. 66 | 67 | ```{r fig.width=8.5} 68 | rental_data %>% 69 | filter(!is.na(`Census Subdivision`)) %>% 70 | mutate(Name=gsub("\\(C\\)","(CY)",`Census Subdivision`)) %>% 71 | mutate(Name=recode(Name, 72 | "Burnaby (DM)"="Burnaby (CY)", 73 | "Coquitlam (DM)"="Coquitlam (CY)", 74 | "Surrey (DM)"="Surrey (CY)")) %>% 75 | filter(Name %in% (filter(.,`Year of Construction`=="Total",Date==max(Date)) %>% 76 | slice_max(Value,n=20) %>% 77 | pull(Name))) %>% 78 | filter(Date==max(Date)|Date==min(Date)) %>% 79 | group_by(Name,`Year of Construction`) %>% 80 | mutate(Change=coalesce(Value,0)-coalesce(lag(Value,order_by = Date),0)) %>% 81 | ungroup() %>% 82 | filter(Date==max(Date)) %>% 83 | mutate(Name=factor(Name,levels=filter(.,`Year of Construction`=="Total") |> arrange(Change) |> pull(Name))) %>% 84 | mutate(`Year of Construction`=factor(`Year of Construction`,levels=rev(levels(`Year of Construction`)))) %>% 85 | ggplot(aes(y=Name,x=Change,fill=`Year of Construction`)) + 86 | geom_bar(data=~filter(.,`Year of Construction`!="Total"), stat="identity") + 87 | geom_point(data=~filter(.,`Year of Construction`=="Total"), 88 | aes(colour=`Year of Construction`),fill="black") + 89 | theme(legend.position = "bottom") + 90 | scale_colour_manual(values=c("Total"="black")) + 91 | scale_x_continuous(labels=scales::comma) + 92 | labs(title="Change in rental stock 1990-2021", 93 | x="Number of units", 94 | y=NULL,colour=NULL, 95 | fill="Period of construction", 96 | caption="CMHC Rms") 97 | ``` 98 | 99 | Over this timeframe the City of Vancouver has added the most rental units, and Burnaby has torn down the most. 100 | 101 | 102 | Another way to slice the data is to look at the net change by number of bedrooms. 103 | 104 | ```{r} 105 | rental_data <- c(1990,2021) |> 106 | lapply(function(y)get_cmhc("Rms","Rental Universe","Bedroom Type","Census Subdivision", 107 | geo_uid="59933",year=y)) %>% 108 | bind_rows() 109 | 110 | rental_data %>% 111 | filter(!is.na(`Census Subdivision`)) %>% 112 | mutate(Name=gsub("\\(C\\)","(CY)",`Census Subdivision`)) %>% 113 | mutate(Name=recode(Name, 114 | "Burnaby (DM)"="Burnaby (CY)", 115 | "Coquitlam (DM)"="Coquitlam (CY)", 116 | "Surrey (DM)"="Surrey (CY)")) %>% 117 | filter(Name %in% (filter(.,`Bedroom Type`=="Total",Date==max(Date)) %>% 118 | slice_max(Value,n=20) %>% 119 | pull(Name))) %>% 120 | filter(Date==max(Date)|Date==min(Date)) %>% 121 | group_by(Name,`Bedroom Type`) %>% 122 | mutate(Change=coalesce(Value,0)-coalesce(lag(Value,order_by = Date),0)) %>% 123 | ungroup() %>% 124 | filter(Date==max(Date)) %>% 125 | mutate(Name=factor(Name,levels=filter(.,`Bedroom Type`=="Total") |> arrange(Change) |> pull(Name))) %>% 126 | ggplot(aes(y=Name,x=Change,fill=`Bedroom Type`)) + 127 | geom_bar(data=~filter(.,`Bedroom Type`!="Total"), stat="identity") + 128 | geom_point(data=~filter(.,`Bedroom Type`=="Total"), 129 | aes(colour=`Bedroom Type`),fill="black") + 130 | theme(legend.position = "bottom") + 131 | scale_colour_manual(values=c("Total"="black")) + 132 | scale_x_continuous(labels=scales::comma) + 133 | labs(title="Change in rental stock 1990-2021", 134 | x="Number of units", 135 | y=NULL,colour=NULL, 136 | fill="Bedroom Type", 137 | caption="CMHC Rms") 138 | ``` 139 | 140 | There are no radical shifts in bedroom types, most municipalities that overall lost rental units lost units of all bedroom types, and municipalities that added rental units added units of all types. On net Vancouver gained mostly 1 and 2 bedroom units, Burnaby lost units of all bedroom types. 141 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • cmhc 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 |
    36 |
    88 | 89 | 90 | 91 | 92 |
    93 |
    94 | 97 | 98 | Content not found. Please use links in the navbar. 99 | 100 |
    101 | 102 | 106 | 107 |
    108 | 109 | 110 | 111 |
    115 | 116 |
    117 |

    118 |

    Site built with pkgdown 2.0.9.

    119 |
    120 | 121 |
    122 |
    123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/LICENSE.html: -------------------------------------------------------------------------------- 1 | 2 | MIT License • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 61 | 62 |
    63 | 64 |

    Copyright (c) 2019 Jens von Bergmann

    65 |

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    66 |

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    67 |

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    68 |
    69 | 70 |
    71 | 72 | 75 | 76 |
    77 | 78 | 79 | 80 |
    89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | Authors and Citation • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 |
    59 | 62 | 63 | 64 |
    69 |
    70 |
    71 |

    Citation

    72 | Source: DESCRIPTION 73 |
    74 |
    75 | 76 | 77 |

    von Bergmann J (2025). 78 | cmhc: Access, Retrieve, and Work with CMHC Data. 79 | R package version 0.2.10, https://mountainmath.github.io/cmhc/, https://www03.cmhc-schl.gc.ca/hmip-pimh/en, https://github.com/mountainMath/cmhc. 80 |

    81 |
    @Manual{,
     82 |   title = {cmhc: Access, Retrieve, and Work with CMHC Data},
     83 |   author = {Jens {von Bergmann}},
     84 |   year = {2025},
     85 |   note = {R package version 0.2.10, https://mountainmath.github.io/cmhc/, https://www03.cmhc-schl.gc.ca/hmip-pimh/en},
     86 |   url = {https://github.com/mountainMath/cmhc},
     87 | }
    88 | 89 |
    90 | 91 |
    92 | 93 | 94 | 95 |
    104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /docs/reference/cmhc_ct_translation_data.html: -------------------------------------------------------------------------------- 1 | 2 | A dataset with geographic identifiers for CMHC and Census at the CT level — cmhc_ct_translation_data • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    A dataset with geographic identifiers for CMHC and Census at the CT level

    66 |
    67 | 68 | 69 |
    70 |

    Format

    71 |

    A tibble with Census and CMHC geographic identifiers

    72 |
    73 |
    74 |

    Source

    75 |

    Custom data extract from CMHC

    76 |
    77 |
    78 |

    Author

    79 |

    derived from CMHC geographic data

    80 |
    81 | 82 |
    83 | 86 |
    87 | 88 | 89 |
    98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /docs/reference/cmhc_cma_translation_data.html: -------------------------------------------------------------------------------- 1 | 2 | A dataset with geographic identifiers for CMHC and Census at the CMA level — cmhc_cma_translation_data • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    A dataset with geographic identifiers for CMHC and Census at the CMA level

    66 |
    67 | 68 | 69 |
    70 |

    Format

    71 |

    A tibble with Census and CMHC geographic identifiers

    72 |
    73 |
    74 |

    Source

    75 |

    Custom data extract from CMHC

    76 |
    77 |
    78 |

    Author

    79 |

    derived from CMHC geographic data

    80 |
    81 | 82 |
    83 | 86 |
    87 | 88 | 89 |
    98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /docs/reference/cmhc_csd_translation_data.html: -------------------------------------------------------------------------------- 1 | 2 | A dataset with geographic identifiers for CMHC and Census at the CSD level — cmhc_csd_translation_data • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    A dataset with geographic identifiers for CMHC and Census at the CSD level

    66 |
    67 | 68 | 69 |
    70 |

    Format

    71 |

    A tibble with Census and CMHC geographic identifiers

    72 |
    73 |
    74 |

    Source

    75 |

    Custom data extract from CMHC

    76 |
    77 |
    78 |

    Author

    79 |

    derived from CMHC geographic data

    80 |
    81 | 82 |
    83 | 86 |
    87 | 88 | 89 |
    98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /docs/reference/cmhc_csd_translation_data_2023.html: -------------------------------------------------------------------------------- 1 | 2 | A dataset with geographic identifiers for CMHC and Census at the CSD level for 2023 data portal version — cmhc_csd_translation_data_2023 • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    A dataset with geographic identifiers for CMHC and Census at the CSD level for 2023 data portal version

    66 |
    67 | 68 | 69 |
    70 |

    Format

    71 |

    A tibble with Census CSD and CMHC METID geographic identifiers

    72 |
    73 |
    74 |

    Source

    75 |

    Custom data extract from CMHC

    76 |
    77 |
    78 |

    Author

    79 |

    derived from CMHC data

    80 |
    81 | 82 |
    83 | 86 |
    87 | 88 | 89 |
    98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /docs/reference/show_cmhc_cache_path.html: -------------------------------------------------------------------------------- 1 | 2 | View saved cache directory path — show_cmhc_cache_path • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    View saved cache path

    66 |
    67 | 68 |
    69 |
    show_cmhc_cache_path()
    70 |
    71 | 72 |
    73 |

    Value

    74 | 75 | 76 |

    a character string with the CMHC cache path

    77 |
    78 | 79 |
    80 |

    Examples

    81 |
    show_cmhc_cache_path()
     82 | #> [1] "/Users/jens/data/cmhc.data"
     83 | 
     84 | 
    85 |
    86 |
    87 | 90 |
    91 | 92 | 93 |
    102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /docs/reference/cmhc_quality_labels.html: -------------------------------------------------------------------------------- 1 | 2 | A list of CMHC quality indicators — cmhc_quality_labels • cmhc 8 | 9 | 10 |
    11 |
    55 | 56 | 57 | 58 |
    59 |
    60 | 65 | 66 |
    67 |

    Data obtained via this package will automatically translate internal CMHC quality labels 68 | using this translation vector, this named vector is useful when working with CMHC data obtained from other 69 | sources like sporadic excel sheets or data scraped from PDF reports.

    70 |
    71 | 72 |
    73 |
    cmhc_quality_labels
    74 |
    75 | 76 |
    77 |

    Format

    78 |

    A named vector to translate internal CMHC quality indicators to plain text.

    79 |
    80 | 81 |
    82 | 85 |
    86 | 87 | 88 |
    97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /docs/reference/select_cmhc_table.html: -------------------------------------------------------------------------------- 1 | 2 | Interactive table selector — select_cmhc_table • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    Interactive table selector

    66 |
    67 | 68 |
    69 |
    select_cmhc_table()
    70 |
    71 | 72 |
    73 |

    Value

    74 | 75 | 76 |

    A string containing the function call to access the selected table

    77 |
    78 | 79 |
    80 |

    Examples

    81 |
    if (FALSE) {
     82 | select_cmhc_table()
     83 | }
     84 | 
    85 |
    86 |
    87 | 90 |
    91 | 92 | 93 |
    102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /docs/reference/list_cmhc_surveys.html: -------------------------------------------------------------------------------- 1 | 2 | List available CMHC surveys — list_cmhc_surveys • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    List available CMHC surveys

    66 |
    67 | 68 |
    69 |
    list_cmhc_surveys()
    70 |
    71 | 72 |
    73 |

    Value

    74 | 75 | 76 |

    A data frame with available survey names.

    77 |
    78 | 79 |
    80 |

    Examples

    81 |
    list_cmhc_surveys()
     82 | #> # A tibble: 6 × 1
     83 | #>   Survey           
     84 | #>   <chr>            
     85 | #> 1 Scss             
     86 | #> 2 Rms              
     87 | #> 3 Srms             
     88 | #> 4 Seniors          
     89 | #> 5 Census           
     90 | #> 6 Core Housing Need
     91 | 
     92 | 
    93 |
    94 |
    95 | 98 |
    99 | 100 | 101 |
    110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /docs/reference/list_cmhc_series.html: -------------------------------------------------------------------------------- 1 | 2 | List available CMHC series — list_cmhc_series • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    List available CMHC series

    66 |
    67 | 68 |
    69 |
    list_cmhc_series(survey = NULL)
    70 |
    71 | 72 |
    73 |

    Arguments

    74 |
    survey
    75 |

    Optional survey to filter by

    76 | 77 |
    78 |
    79 |

    Value

    80 | 81 | 82 |

    A data frame with survey names, and available series names.

    83 |
    84 | 85 |
    86 |

    Examples

    87 |
    list_cmhc_series("Rms")
     88 | #> # A tibble: 7 × 2
     89 | #>   Survey Series             
     90 | #>   <chr>  <chr>              
     91 | #> 1 Rms    Vacancy Rate       
     92 | #> 2 Rms    Availability Rate  
     93 | #> 3 Rms    Average Rent       
     94 | #> 4 Rms    Average Rent Change
     95 | #> 5 Rms    Median Rent        
     96 | #> 6 Rms    Rental Universe    
     97 | #> 7 Rms    Summary Statistics 
     98 | 
     99 | 
    100 |
    101 |
    102 | 105 |
    106 | 107 | 108 |
    117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /docs/pkgdown.css: -------------------------------------------------------------------------------- 1 | /* Sticky footer */ 2 | 3 | /** 4 | * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ 5 | * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css 6 | * 7 | * .Site -> body > .container 8 | * .Site-content -> body > .container .row 9 | * .footer -> footer 10 | * 11 | * Key idea seems to be to ensure that .container and __all its parents__ 12 | * have height set to 100% 13 | * 14 | */ 15 | 16 | html, body { 17 | height: 100%; 18 | } 19 | 20 | body { 21 | position: relative; 22 | } 23 | 24 | body > .container { 25 | display: flex; 26 | height: 100%; 27 | flex-direction: column; 28 | } 29 | 30 | body > .container .row { 31 | flex: 1 0 auto; 32 | } 33 | 34 | footer { 35 | margin-top: 45px; 36 | padding: 35px 0 36px; 37 | border-top: 1px solid #e5e5e5; 38 | color: #666; 39 | display: flex; 40 | flex-shrink: 0; 41 | } 42 | footer p { 43 | margin-bottom: 0; 44 | } 45 | footer div { 46 | flex: 1; 47 | } 48 | footer .pkgdown { 49 | text-align: right; 50 | } 51 | footer p { 52 | margin-bottom: 0; 53 | } 54 | 55 | img.icon { 56 | float: right; 57 | } 58 | 59 | /* Ensure in-page images don't run outside their container */ 60 | .contents img { 61 | max-width: 100%; 62 | height: auto; 63 | } 64 | 65 | /* Fix bug in bootstrap (only seen in firefox) */ 66 | summary { 67 | display: list-item; 68 | } 69 | 70 | /* Typographic tweaking ---------------------------------*/ 71 | 72 | .contents .page-header { 73 | margin-top: calc(-60px + 1em); 74 | } 75 | 76 | dd { 77 | margin-left: 3em; 78 | } 79 | 80 | /* Section anchors ---------------------------------*/ 81 | 82 | a.anchor { 83 | display: none; 84 | margin-left: 5px; 85 | width: 20px; 86 | height: 20px; 87 | 88 | background-image: url(./link.svg); 89 | background-repeat: no-repeat; 90 | background-size: 20px 20px; 91 | background-position: center center; 92 | } 93 | 94 | h1:hover .anchor, 95 | h2:hover .anchor, 96 | h3:hover .anchor, 97 | h4:hover .anchor, 98 | h5:hover .anchor, 99 | h6:hover .anchor { 100 | display: inline-block; 101 | } 102 | 103 | /* Fixes for fixed navbar --------------------------*/ 104 | 105 | .contents h1, .contents h2, .contents h3, .contents h4 { 106 | padding-top: 60px; 107 | margin-top: -40px; 108 | } 109 | 110 | /* Navbar submenu --------------------------*/ 111 | 112 | .dropdown-submenu { 113 | position: relative; 114 | } 115 | 116 | .dropdown-submenu>.dropdown-menu { 117 | top: 0; 118 | left: 100%; 119 | margin-top: -6px; 120 | margin-left: -1px; 121 | border-radius: 0 6px 6px 6px; 122 | } 123 | 124 | .dropdown-submenu:hover>.dropdown-menu { 125 | display: block; 126 | } 127 | 128 | .dropdown-submenu>a:after { 129 | display: block; 130 | content: " "; 131 | float: right; 132 | width: 0; 133 | height: 0; 134 | border-color: transparent; 135 | border-style: solid; 136 | border-width: 5px 0 5px 5px; 137 | border-left-color: #cccccc; 138 | margin-top: 5px; 139 | margin-right: -10px; 140 | } 141 | 142 | .dropdown-submenu:hover>a:after { 143 | border-left-color: #ffffff; 144 | } 145 | 146 | .dropdown-submenu.pull-left { 147 | float: none; 148 | } 149 | 150 | .dropdown-submenu.pull-left>.dropdown-menu { 151 | left: -100%; 152 | margin-left: 10px; 153 | border-radius: 6px 0 6px 6px; 154 | } 155 | 156 | /* Sidebar --------------------------*/ 157 | 158 | #pkgdown-sidebar { 159 | margin-top: 30px; 160 | position: -webkit-sticky; 161 | position: sticky; 162 | top: 70px; 163 | } 164 | 165 | #pkgdown-sidebar h2 { 166 | font-size: 1.5em; 167 | margin-top: 1em; 168 | } 169 | 170 | #pkgdown-sidebar h2:first-child { 171 | margin-top: 0; 172 | } 173 | 174 | #pkgdown-sidebar .list-unstyled li { 175 | margin-bottom: 0.5em; 176 | } 177 | 178 | /* bootstrap-toc tweaks ------------------------------------------------------*/ 179 | 180 | /* All levels of nav */ 181 | 182 | nav[data-toggle='toc'] .nav > li > a { 183 | padding: 4px 20px 4px 6px; 184 | font-size: 1.5rem; 185 | font-weight: 400; 186 | color: inherit; 187 | } 188 | 189 | nav[data-toggle='toc'] .nav > li > a:hover, 190 | nav[data-toggle='toc'] .nav > li > a:focus { 191 | padding-left: 5px; 192 | color: inherit; 193 | border-left: 1px solid #878787; 194 | } 195 | 196 | nav[data-toggle='toc'] .nav > .active > a, 197 | nav[data-toggle='toc'] .nav > .active:hover > a, 198 | nav[data-toggle='toc'] .nav > .active:focus > a { 199 | padding-left: 5px; 200 | font-size: 1.5rem; 201 | font-weight: 400; 202 | color: inherit; 203 | border-left: 2px solid #878787; 204 | } 205 | 206 | /* Nav: second level (shown on .active) */ 207 | 208 | nav[data-toggle='toc'] .nav .nav { 209 | display: none; /* Hide by default, but at >768px, show it */ 210 | padding-bottom: 10px; 211 | } 212 | 213 | nav[data-toggle='toc'] .nav .nav > li > a { 214 | padding-left: 16px; 215 | font-size: 1.35rem; 216 | } 217 | 218 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 219 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 220 | padding-left: 15px; 221 | } 222 | 223 | nav[data-toggle='toc'] .nav .nav > .active > a, 224 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 225 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 226 | padding-left: 15px; 227 | font-weight: 500; 228 | font-size: 1.35rem; 229 | } 230 | 231 | /* orcid ------------------------------------------------------------------- */ 232 | 233 | .orcid { 234 | font-size: 16px; 235 | color: #A6CE39; 236 | /* margins are required by official ORCID trademark and display guidelines */ 237 | margin-left:4px; 238 | margin-right:4px; 239 | vertical-align: middle; 240 | } 241 | 242 | /* Reference index & topics ----------------------------------------------- */ 243 | 244 | .ref-index th {font-weight: normal;} 245 | 246 | .ref-index td {vertical-align: top; min-width: 100px} 247 | .ref-index .icon {width: 40px;} 248 | .ref-index .alias {width: 40%;} 249 | .ref-index-icons .alias {width: calc(40% - 40px);} 250 | .ref-index .title {width: 60%;} 251 | 252 | .ref-arguments th {text-align: right; padding-right: 10px;} 253 | .ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} 254 | .ref-arguments .name {width: 20%;} 255 | .ref-arguments .desc {width: 80%;} 256 | 257 | /* Nice scrolling for wide elements --------------------------------------- */ 258 | 259 | table { 260 | display: block; 261 | overflow: auto; 262 | } 263 | 264 | /* Syntax highlighting ---------------------------------------------------- */ 265 | 266 | pre, code, pre code { 267 | background-color: #f8f8f8; 268 | color: #333; 269 | } 270 | pre, pre code { 271 | white-space: pre-wrap; 272 | word-break: break-all; 273 | overflow-wrap: break-word; 274 | } 275 | 276 | pre { 277 | border: 1px solid #eee; 278 | } 279 | 280 | pre .img, pre .r-plt { 281 | margin: 5px 0; 282 | } 283 | 284 | pre .img img, pre .r-plt img { 285 | background-color: #fff; 286 | } 287 | 288 | code a, pre a { 289 | color: #375f84; 290 | } 291 | 292 | a.sourceLine:hover { 293 | text-decoration: none; 294 | } 295 | 296 | .fl {color: #1514b5;} 297 | .fu {color: #000000;} /* function */ 298 | .ch,.st {color: #036a07;} /* string */ 299 | .kw {color: #264D66;} /* keyword */ 300 | .co {color: #888888;} /* comment */ 301 | 302 | .error {font-weight: bolder;} 303 | .warning {font-weight: bolder;} 304 | 305 | /* Clipboard --------------------------*/ 306 | 307 | .hasCopyButton { 308 | position: relative; 309 | } 310 | 311 | .btn-copy-ex { 312 | position: absolute; 313 | right: 0; 314 | top: 0; 315 | visibility: hidden; 316 | } 317 | 318 | .hasCopyButton:hover button.btn-copy-ex { 319 | visibility: visible; 320 | } 321 | 322 | /* headroom.js ------------------------ */ 323 | 324 | .headroom { 325 | will-change: transform; 326 | transition: transform 200ms linear; 327 | } 328 | .headroom--pinned { 329 | transform: translateY(0%); 330 | } 331 | .headroom--unpinned { 332 | transform: translateY(-100%); 333 | } 334 | 335 | /* mark.js ----------------------------*/ 336 | 337 | mark { 338 | background-color: rgba(255, 255, 51, 0.5); 339 | border-bottom: 2px solid rgba(255, 153, 51, 0.3); 340 | padding: 1px; 341 | } 342 | 343 | /* vertical spacing after htmlwidgets */ 344 | .html-widget { 345 | margin-bottom: 10px; 346 | } 347 | 348 | /* fontawesome ------------------------ */ 349 | 350 | .fab { 351 | font-family: "Font Awesome 5 Brands" !important; 352 | } 353 | 354 | /* don't display links in code chunks when printing */ 355 | /* source: https://stackoverflow.com/a/10781533 */ 356 | @media print { 357 | code a:link:after, code a:visited:after { 358 | content: ""; 359 | } 360 | } 361 | 362 | /* Section anchors --------------------------------- 363 | Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 364 | */ 365 | 366 | div.csl-bib-body { } 367 | div.csl-entry { 368 | clear: both; 369 | } 370 | .hanging-indent div.csl-entry { 371 | margin-left:2em; 372 | text-indent:-2em; 373 | } 374 | div.csl-left-margin { 375 | min-width:2em; 376 | float:left; 377 | } 378 | div.csl-right-inline { 379 | margin-left:2em; 380 | padding-left:1em; 381 | } 382 | div.csl-indent { 383 | margin-left: 2em; 384 | } 385 | -------------------------------------------------------------------------------- /docs/reference/list_cmhc_dimensions.html: -------------------------------------------------------------------------------- 1 | 2 | List available CMHC dimensions — list_cmhc_dimensions • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    List available CMHC dimensions

    66 |
    67 | 68 |
    69 |
    list_cmhc_dimensions(survey = NULL, series = NULL)
    70 |
    71 | 72 |
    73 |

    Arguments

    74 |
    survey
    75 |

    Optional survey to filter by

    76 | 77 | 78 |
    series
    79 |

    Optional series to filter by

    80 | 81 |
    82 |
    83 |

    Value

    84 | 85 | 86 |

    A data frame with survey names, series names, and available dimension names.

    87 |
    88 | 89 |
    90 |

    Examples

    91 |
    list_cmhc_dimensions("Rms","Vacancy Rate")
     92 | #> # A tibble: 5 × 3
     93 | #>   Survey Series       Dimension           
     94 | #>   <chr>  <chr>        <chr>               
     95 | #> 1 Rms    Vacancy Rate Bedroom Type        
     96 | #> 2 Rms    Vacancy Rate Year of Construction
     97 | #> 3 Rms    Vacancy Rate Structure Size      
     98 | #> 4 Rms    Vacancy Rate Rent Ranges         
     99 | #> 5 Rms    Vacancy Rate Rent Quartiles      
    100 | 
    101 | 
    102 |
    103 |
    104 | 107 |
    108 | 109 | 110 |
    119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /docs/reference/list_cmhc_filters.html: -------------------------------------------------------------------------------- 1 | 2 | List available CMHC filters — list_cmhc_filters • cmhc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    List available CMHC filters

    66 |
    67 | 68 |
    69 |
    list_cmhc_filters(
     70 |   survey = NULL,
     71 |   series = NULL,
     72 |   dimension = NULL,
     73 |   breakdown = NULL
     74 | )
    75 |
    76 | 77 |
    78 |

    Arguments

    79 |
    survey
    80 |

    Optional survey to filter by

    81 | 82 | 83 |
    series
    84 |

    Optional series to filter by

    85 | 86 | 87 |
    dimension
    88 |

    Optional dimension to filter by

    89 | 90 | 91 |
    breakdown
    92 |

    Optional breakdown to filter by

    93 | 94 |
    95 |
    96 |

    Value

    97 | 98 | 99 |

    A data frame with available filters

    100 |
    101 | 102 |
    103 |

    Examples

    104 |
    list_cmhc_filters("Rms","Vacancy Rate","Bedroom Type","Historical Time Periods")
    105 | #> # A tibble: 1 × 5
    106 | #>   Survey Series       Dimension    Breakdown               Filters         
    107 | #>   <chr>  <chr>        <chr>        <chr>                   <list>          
    108 | #> 1 Rms    Vacancy Rate Bedroom Type Historical Time Periods <named list [2]>
    109 | 
    110 | 
    111 |
    112 |
    113 | 116 |
    117 | 118 | 119 |
    128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /docs/reference/set_cmhc_cache_path.html: -------------------------------------------------------------------------------- 1 | 2 | Set persistent cmhc cache location for geographic data — set_cmhc_cache_path • cmhc 8 | 9 | 10 |
    11 |
    55 | 56 | 57 | 58 |
    59 |
    60 | 65 | 66 |
    67 |

    The cmhc package provides access to custom cmhc geographies, these are large files and should be 68 | stored in a permanent location. This function sets the CMHC_CACHE_PATH environment variable and optionally 69 | installs it in the .Renviron file for future use. This is only needed when using the `get_cmhc_geography()` function.

    70 |
    71 | 72 |
    73 |
    set_cmhc_cache_path(cache_path, overwrite = FALSE, install = FALSE)
    74 |
    75 | 76 |
    77 |

    Arguments

    78 |
    cache_path
    79 |

    a local directory to use for saving cached data

    80 | 81 | 82 |
    overwrite
    83 |

    Option to overwrite any existing cache path already stored locally.

    84 | 85 | 86 |
    install
    87 |

    Option to install permanently for use across sessions.

    88 | 89 |
    90 |
    91 |

    Value

    92 | 93 | 94 |

    a character string with the CMHC cache path

    95 |
    96 | 97 |
    98 |

    Examples

    99 |
    if (FALSE) {
    100 | # This sets the cache path for the duration of the current session
    101 | set_cmhc_cache_path("~/cmhc_cache")
    102 | 
    103 | # This will set the cache path permanently until overwritten again
    104 | set_cmhc_cache_path("~/cmhc_cache", install = TRUE)
    105 | }
    106 | 
    107 | 
    108 |
    109 |
    110 | 113 |
    114 | 115 | 116 |
    125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | --------------------------------------------------------------------------------