Skip to content

Commit 3855475

Browse files
committed
flesh out 1996
1 parent 92bad08 commit 3855475

9 files changed

Lines changed: 50 additions & 38 deletions

File tree

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# cancensus 0.3.2
22

3-
## Minor changes
3+
## Major changes
44
- Support for 1996 census
5+
- Public availability of dissemination block area level data
6+
7+
## Minor changes
8+
- Fixes [bug](https://github.com/mountainMath/cancensus/issues/150) in `find_census_vectors()`
59

610
# cancensus 0.3.1
711

R/cancensus.R

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ get_census <- function (dataset, regions, level=NA, vectors=c(), geo_format = NA
5454

5555
# Turn the region list into a valid JSON dictionary.
5656
if (is.character(regions)) {
57-
if (!quiet) warning(paste("passing `regions` as a character vector is",
57+
if (!quiet) warning(paste("Passing `regions` as a character vector is",
5858
"depreciated, and will be removed in future",
5959
"versions"))
6060
} else if (is.null(names(regions)) || !all(names(regions) %in% VALID_LEVELS)) {
61-
stop("regions must be composed of valid census aggregation levels.")
61+
stop("Regions must be composed of valid census aggregation levels.")
6262
} else {
6363
regions <- jsonlite::toJSON(lapply(regions,as.character)) # cast to character in case regions are supplied as numeric/interger
6464
}
@@ -319,9 +319,6 @@ dataset_attribution <- function(datasets){
319319

320320
commons %>% lapply(function(c){
321321
matches <- attribution[grepl(paste0("^",c,"$"),attribution)]
322-
323-
#years <- stringr::str_extract(matches, "\\d{4}") %>% sort()
324-
# avoid stringr dependency
325322
parts <- strsplit(c, split = "\\\\d\\{4\\}") %>%
326323
unlist()
327324
years <- matches
@@ -336,8 +333,6 @@ dataset_attribution <- function(datasets){
336333
paste0(collapse="; ")
337334
}
338335

339-
340-
341336
#' Return Census variable names and labels as a tidy data frame
342337
#'
343338
#' @param x A data frame, \code{sp} or \code{sf} object returned from

R/census_regions.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@
3636
#' @examples
3737
#' list_census_regions('CA16')
3838
list_census_regions <- function(dataset, use_cache = TRUE, quiet = FALSE) {
39-
dataset = toupper(dataset)
4039
cache_file <- file.path(tempdir(),paste0(dataset, "_regions.rda"))
41-
#cache_file <- cache_path(dataset, "_regions.rda")
40+
4241
if (!use_cache || !file.exists(cache_file)) {
4342
if (!quiet) message("Querying CensusMapper API for regions data...")
4443
response <- httr::GET(paste0("https://censusmapper.ca/data_sets/", dataset,

R/census_vectors.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#' # List all vectors for a given Census dataset in CensusMapper
2626
#' list_census_vectors('CA16')
2727
list_census_vectors <- function(dataset, use_cache = TRUE, quiet = TRUE) {
28-
#cache_file <- cache_path(dataset, "_vectors.rda")
2928
cache_file <- file.path(tempdir(),paste0(dataset, "_vectors.rda"))
3029
if (!use_cache || !file.exists(cache_file)) {
3130
url <- paste0(cancensus_base_url(),"/api/v1/vector_info/", dataset, ".csv")

R/helpers.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ as.int = function(x, na.strings = cancensus_na_strings) {
5252
x
5353
}
5454

55-
# To activate later
56-
# valid_datasets <- c("CA01","CA06","CA11","CA16",
55+
# List of eligible datasets
56+
# VALID_DATASETS <- c("CA1996","CA01","CA06","CA11","CA16",
5757
# "CA01xSD", "CA06xSD", "CA11xSD", "CA16xSD",
5858
# "TX2000", "TX2001", "TX2002", "TX2003", "TX2004",
5959
# "TX2005", "TX2006", "TX2007", "TX2008", "TX2009",

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ library(cancensus)
3535

3636
### API key
3737

38-
This package relies on queries to the CensusMapper API, which requires a Censusmapper API key. You can obtain a free API key by [signing up](https://censusmapper.ca/users/sign_up) for a CensusMapper account. CensusMapper API keys are free; however, API requests are limited in volume. For larger quotas, please get in touch with Jens [directly](mailto:jens@censusmapper.ca).
38+
**cancensus** requires a valid CensusMapper API key to use. You can obtain a free API key by [signing up](https://censusmapper.ca/users/sign_up) for a CensusMapper account. CensusMapper API keys are free and public API quotas are generous; however, due to incremental costs of serving large quantities of data, there limits to API usage in place. For most use cases, these API limits should not be an issue. Production uses with large extracts of fine grained geographies may run into API quota limits. For larger quotas, please get in touch with Jens [directly](mailto:jens@censusmapper.ca).
3939

4040
To check your API key, just go to "Edit Profile" (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter `options(cancensus.api_key = "your_api_key")`.
4141

@@ -45,7 +45,7 @@ For performance reasons, and to avoid unnecessarily drawing down API quotas, **c
4545

4646
### Currently available datasets
4747

48-
**cancensus** can access Statistics Canada Census data for the 2001 Census, the 2006 Census, the 2011 Census and National Household Survey, as well as the 2016 Census. You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2016 Census will be included in Censusmapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2016 Program which can be viewed on their [website](http://www12.statcan.gc.ca/census-recensement/2016/ref/release-dates-diffusion-eng.cfm).
48+
**cancensus** can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, and 2016. You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2016 Census will be included in Censusmapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2016 Program which can be viewed on their [website](http://www12.statcan.gc.ca/census-recensement/2016/ref/release-dates-diffusion-eng.cfm).
4949

5050
Thanks to contributions by the Canada Mortgage and Housing Corporation (CMHC), **cancensus** now includes additional Census-linked datasets as open-data releases. These include annual taxfiler data at the census tract level for tax years 2000 through 2017, which includes data on incomes and demographics, as well as specialized crosstabs for Structural type of dwelling by Document type, which details occupancy status for residences. These crosstabs are available for the 2001, 2006, 2011, and 2016 Census years at all levels starting with census tract.
5151

cran-comments.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Update - v.0.3.2
22

3-
Add functionality for 1996 census
3+
- Add functionality for 1996 census and more refined geographies
4+
- Expanded vignettes
5+
- Fix minor bugs flagged by users
46

57
## Update - v.0.3.1
68

vignettes/cancensus.Rmd

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ As Statistics Canada does not provide direct API access to Census data, **cancen
2929

3030
## API Key
3131

32-
**cancensus** requires a valid CensusMapper API key to use. You can obtain a free API key by [signing up](https://censusmapper.ca/users/sign_up) for a CensusMapper account. CensusMapper API keys are free; however, API requests are limited in volume. For larger quotas, please get in touch with Jens [directly](mailto:jens@censusmapper.ca).
32+
**cancensus** requires a valid CensusMapper API key to use. You can obtain a free API key by [signing up](https://censusmapper.ca/users/sign_up) for a CensusMapper account. CensusMapper API keys are free and public API quotas are generous; however, due to incremental costs of serving large quantities of data, there limits to API usage in place. For most use cases, these API limits should not be an issue. Production uses with large extracts of fine grained geographies may run into API quota limits. For larger quotas, please get in touch with Jens [directly](mailto:jens@censusmapper.ca).
3333

3434
To check your API key, just go to "Edit Profile" (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter `options(cancensus.api_key = "your_api_key")`.
3535

@@ -92,7 +92,7 @@ Additional parameters for advanced options can be viewed by running `?get_census
9292

9393
## Census Datasets
9494

95-
**cancensus** can access Statistics Canada Census data for the 2001 Census, the 2006 Census, the 2011 Census and National Household Survey, as well as the 2016 Census. You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2016 Census will be included in Censusmapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2016 Program which can be viewed on their [website](http://www12.statcan.gc.ca/census-recensement/2016/ref/release-dates-diffusion-eng.cfm).
95+
**cancensus** can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, and 2016 . You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2016 Census will be included in Censusmapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2016 Program which can be viewed on their [website](http://www12.statcan.gc.ca/census-recensement/2016/ref/release-dates-diffusion-eng.cfm).
9696

9797
Thanks to contributions by the Canada Mortgage and Housing Corporation (CMHC), **cancensus** now includes additional Census-linked datasets as open-data releases. These include annual taxfiler data at the census tract level for tax years 2000 through 2017, which includes data on incomes and demographics, as well as specialized crosstabs for Structural type of dwelling by Document type, which details occupancy status for residences. These crosstabs are available for the 2001, 2006, 2011, and 2016 Census years at all levels starting with census tract.
9898

@@ -130,19 +130,21 @@ census_data <- get_census(dataset='CA16', regions=list(CMA=c("59933","35535")),
130130

131131
Census data accessible through **cancensus** comes is available in a number of different aggregation levels including:
132132

133-
| Code | Description | Count in Census 2016 |
134-
| --------|-------------------------------|:--------------------:|
135-
| C | Canada (total) | 1 |
136-
| PR | Provinces/Territories | 13 |
137-
| CMA | Census Metropolitan Area | 35 |
138-
| CA | Census Agglomeration | 14 |
139-
| CD | Census Division | 287 |
140-
| CSD | Census Subdivision | 713 |
141-
| CT | Census Tracts | 5621 |
142-
| DA | Dissemination Area | 56589 |
143-
| Regions | Named Census Region | |
144-
145-
Selecting `regions = "59933"` and `level = "CT"` will return data for all 478 census tracts in the Vancouver Census Metropolitan Area. Selecting `level = "DA"` will return data for all 3450 dissemination areas. Working with CT and DA level data significantly increases the size of data downloads and API usage. **cancensus** relies on local data caching to reduce usage and load times.
133+
| Code | Description | Count in Census 2016 |
134+
| --------|--------------------------------|:--------------------:|
135+
| C | Canada (total) | 1 |
136+
| PR | Provinces/Territories | 13 |
137+
| CMA | Census Metropolitan Area | 35 |
138+
| CA | Census Agglomeration | 14 |
139+
| CD | Census Division | 287 |
140+
| CSD | Census Subdivision | 713 |
141+
| CT | Census Tracts | 5621 |
142+
| DA | Dissemination Area | 56589 |
143+
| EA | Enumeration Area (1996 only) | - |
144+
| DB | Dissemination Block (2001-2016)| 489676 |
145+
| Regions | Named Census Region | |
146+
147+
Selecting `regions = "59933"` and `level = "CT"` will return data for all 478 census tracts in the Vancouver Census Metropolitan Area. Selecting `level = "DA"` will return data for all 3450 dissemination areas and selecting `level = "DB"` will retrieve data for 15,197 dissemination block. Working with CT, DA, EA, and especially DB level data significantly increases the size of data downloads and API usage. To help minimize additional overhead, **cancensus** supports local data caching to reduce usage and load times.
146148

147149
Setting `level = "Regions"` will produce data strictly for the selected region without any tiling of data at lower census aggregation levels levels.
148150

@@ -197,7 +199,7 @@ Sometimes we want to traverse the hierarchy in the opposite direction. This is f
197199

198200
```{r child_vectors1, message=FALSE, warning=FALSE}
199201
# Find the variable indicating the Northern European aggregate
200-
search_census_vectors("Northern European", dataset = 'CA16')
202+
find_census_vectors("Northern European", dataset = "CA16", type = "Total")
201203
```
202204

203205
The search result shows that the vector **v_CA16_4092** represents the aggregate for all Northern European origins. The `child_census_vectors` function can return a list of its constituent underlying variables.

0 commit comments

Comments
 (0)