Package cancensus. February 4, 2018

Similar documents
Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package postgistools

Package calpassapi. August 25, 2018

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package qualmap. R topics documented: September 12, Type Package

Package messaging. May 27, 2018

Package tidytransit. March 4, 2019

Package facerec. May 14, 2018

Package fingertipsr. May 25, Type Package Version Title Fingertips Data for Public Health

Package censusapi. August 19, 2018

Package statsdk. September 30, 2017

Package jpmesh. December 4, 2017

Package fastdummies. January 8, 2018

Package bisect. April 16, 2018

Package rbgm. May 18, 2018

Package rzeit2. January 7, 2019

Package SEMrushR. November 3, 2018

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package docxtools. July 6, 2018

Package robotstxt. November 12, 2017

Package geogrid. August 19, 2018

Package gtrendsr. October 19, 2017

Package repec. August 31, 2018

Package githubinstall

Package fitbitscraper

Package oec. R topics documented: May 11, Type Package

Package gtrendsr. August 4, 2018

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package rcv. August 11, 2017

Package wrswor. R topics documented: February 2, Type Package

Package guardianapi. February 3, 2019

Package algorithmia. September 13, 2016

Package postal. July 27, 2018

Package goodpractice

Package opencage. January 16, 2018

Package dkanr. July 12, 2018

Package ezsummary. August 29, 2016

Package internetarchive

Package sfdct. August 29, 2017

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package humanize. R topics documented: April 4, Version Title Create Values for Human Consumption

Package rgho. R topics documented: January 18, 2017

Package omu. August 2, 2018

Package ECctmc. May 1, 2018

Package validara. October 19, 2017

Package embed. November 19, 2018

Package rnaturalearth

Package knitrprogressbar

Package areal. December 31, 2018

Package splithalf. March 17, 2018

Package widyr. August 14, 2017

Package comparedf. February 11, 2019

Package virustotal. May 1, 2017

Package patentsview. July 12, 2017

Package rpostgislt. March 2, 2018

Package wikitaxa. December 21, 2017

Package WordR. September 7, 2017

Package fastqcr. April 11, 2017

Package data.world. April 5, 2018

Package loggit. April 9, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package rmapzen. October 7, 2018

Package tiler. June 9, 2018

Package datasets.load

Package spelling. December 18, 2017

Package httpcache. October 17, 2017

Package rsppfp. November 20, 2018

Package nngeo. September 29, 2018

Package vinereg. August 10, 2018

Package barcoder. October 26, 2018

Package ecoseries. R topics documented: September 27, 2017

Package states. May 4, 2018

Package glue. March 12, 2019

Package queuecomputer

Package sfc. August 29, 2016

Package canvasxpress

Package phonics. February 13, Type Package Title Phonetic Spelling Algorithms Version Date Encoding UTF-8

Package TrafficBDE. March 1, 2018

Package vip. June 15, 2018

Package raker. October 10, 2017

Package anomalize. April 17, 2018

Package balance. October 12, 2018

Package ClustGeo. R topics documented: July 14, Type Package

Package kdtools. April 26, 2018

Package tibble. August 22, 2017

Package ruler. February 23, 2018

Package condusco. November 8, 2017

Package auctestr. November 13, 2017

Package tidylpa. March 28, 2018

Package rgdax. January 7, 2019

Package geniusr. December 6, 2017

Package rwars. January 14, 2017

Package nlgeocoder. October 8, 2018

Package zoomgrid. January 3, 2019

Package textrecipes. December 18, 2018

Package tidytree. June 13, 2018

Package meme. November 2, 2017

Package keyholder. May 19, 2018

Package rcmdcheck. R topics documented: November 10, 2018

Package semver. January 6, 2017

Transcription:

Type Package Package cancensus February 4, 2018 Title Canadian Census Data and Geography from the 'CensusMapper' API Version 0.1.7 Integrated, convenient, and uniform access to Canadian Census data and geography retrieved using the 'CensusMapper' API. This package produces analysis-ready tidy data frames and spatial data in multiple formats, as well as convenience functions for working with Census variables, variable hierarchies, and region selection. API keys are freely available with free registration at <https://censusmapper.ca/api>. Census data and boundary geometries are reproduced and distributed on an ``as is'' basis with the permission of Statistics Canada (Statistics Canada 2006; 2011; 2016). License MIT + file LICENSE Encoding UTF-8 LazyData yes ByteCompile yes NeedsCompilation no Imports digest (>= 0.1), dplyr (>= 0.7), httr (>= 1.0.0), jsonlite (>= 1.0), rlang RoxygenNote 6.0.1 Suggests knitr, ggplot2, leaflet, rmarkdown, readr, rgdal, rgeos, scales, sf, sp, tidyr VignetteBuilder knitr URL https://github.com/mountainmath/cancensus, https://mountainmath.github.io/cancensus/, https://censusmapper.ca/api BugReports https://github.com/mountainmath/cancensus/issues Author Jens von Bergmann [aut] (API creator and maintainer), Dmitry Shkolnik [aut, cre] (Package maintainer, responsible for correspondence), Aaron Jacobs [aut] 1

2 as_census_region_list Maintainer Dmitry Shkolnik <shkolnikd@gmail.com> Repository CRAN Date/Publication 2018-02-04 14:54:06 UTC R topics documented: as_census_region_list.................................... 2 census_vectors....................................... 3 child_census_vectors.................................... 4 get_census.......................................... 4 label_vectors........................................ 6 list_census_datasets..................................... 7 list_census_regions..................................... 7 list_census_vectors..................................... 8 parent_census_vectors................................... 9 search_census_regions................................... 10 search_census_vectors................................... 10 Index 12 as_census_region_list Convert a (suitably filtered) data frame from list_census_regions to a list suitable for passing to get_census. Convert a (suitably filtered) data frame from list_census_regions to a list suitable for passing to get_census. as_census_region_list(tbl) tbl A data frame, suitably filtered, as returned by list_census_regions. library(dplyr, warn.conflicts = FALSE) # Query the CensusMapper API for the total occupied dwellings # of 20 random Census Subdivisions, in Census 2016. regions <- list_census_regions("ca16") %>% filter(level == "CSD") %>% sample_n(20) %>% as_census_region_list()

census_vectors 3 occupied <- get_census("ca16", regions = regions, vectors = c("v_ca16_408"), level = "Regions") census_vectors Return Census variable names and labels as a tidy data frame (Deprecated) Return Census variable names and labels as a tidy data frame (Deprecated) census_vectors(x) x A data frame, sp or sf object returned from get_census or similar. Value A data frame with a column variable containing the truncated variable name, and a column label describing it. # Query census data with truncated labels: census_data <- get_census(dataset='ca16', regions=list(cma="59933"), vectors=c("v_ca16_408","v_ca16_409","v_ca16_410"), level='csd', geo_format = "sf", labels="short") # Get details for truncated vectors: census_vectors(census_data)

4 get_census child_census_vectors List all child variables from vector hierarchical based on a (sub- )list of census variables returned by list_census_vectors or search_census_vectors. List all child variables from vector hierarchical based on a (sub-)list of census variables returned by list_census_vectors or search_census_vectors. child_census_vectors(vector_list, leaves_only = FALSE) vector_list leaves_only The list of vectors to be used Boolean flag to indicate if only leaf vectors should be returned, i.e. vectors that don t have children library(dplyr, warn.conflicts = FALSE) list_census_vectors("ca16") %>% filter(vector == "v_ca16_4092") %>% child_census_vectors(true) get_census Access to Canadian census data through the CensusMapper API This function allows convenient access to Canadian census data and boundary files through the CensusMapper API. An API key is required to retrieve data. get_census(dataset, level, regions, vectors = c(), geo_format = NA, labels = "detailed", use_cache = TRUE, quiet = FALSE, api_key = getoption("cancensus.api_key")) get_census_geometry(dataset, level, regions, geo_format = "sf",...)

get_census 5 Details Source dataset level regions vectors geo_format labels use_cache quiet api_key A CensusMapper dataset identifier. The census aggregation level to retrieve. One of "Regions", "PR", "CMA", "CD", "CSD", "CT" or "DA". A named list of census regions to retrieve. Names must be valid census aggregation levels. An R vector containing the CensusMapper variable names of the census variables to download. If no vectors are specified only geographic data will get downloaded. By default is set to NA and appends no geographic information. To include geographic information with census data, specify one of either "sf" to return an sf object (requires the sf package) or "sp" to return a SpatialPolygonsDataFrame object (requires the rgdal package). Set to "detailed" by default, but truncated Census variable names can be selected by setting labels = "short". Use label_vectors(...) to return variable label information in detail. If set to TRUE (the default) data will be read from the local cache if available. When TRUE, suppress messages and warnings. An API key for the CensusMapper API. Defaults to options() and then the CM_API_KEY environment variable.... Further arguments passed to get_census. get_census_geometry is a convenience function that retrieves only Census geography boundaries. For help selecting regions and vectors, see list_census_regions and list_census_vectors, or check out the interactive selection tool at https://censusmapper.ca/api. Census data and boundary geographies are reproduced and distributed on an "as is" basis with the permission of Statistics Canada (Statistics Canada 2006; 2011; 2016). # Query the API for data on dwellings in Vancouver, at the census subdivision # level: census_data <- get_census(dataset='ca16', regions=list(cma="59933"), vectors=c("v_ca16_408","v_ca16_409","v_ca16_410"), level='csd') # Query the API for data on dwellings in Vancouver, at the census subdivision # level, and return the associated geography files in \code{sf} format: census_data <- get_census(dataset='ca16', regions=list(cma="59933"), vectors=c("v_ca16_408","v_ca16_409","v_ca16_410"),

6 label_vectors level='csd', geo_format = "sf") # Make the same query, but return geography in \code{sp} format: census_data <- get_census(dataset='ca16', regions=list(cma="59933"), vectors=c("v_ca16_408","v_ca16_409","v_ca16_410"), level='csd', geo_format = "sf") # Make the same query, but this time drop descriptive vector names: census_data <- get_census(dataset='ca16', regions=list(cma="59933"), vectors=c("v_ca16_408","v_ca16_409","v_ca16_410"), level='csd', geo_format = "sf", labels="short") # Get details for truncated vectors: label_vectors(census_data) # Query the API for census subdivision boundary geometry within Vancouver. vc_csds <- get_census_geometry(dataset='ca16', regions=list(cma="59933"), level='csd', geo_format = "sf") label_vectors Return Census variable names and labels as a tidy data frame Return Census variable names and labels as a tidy data frame label_vectors(x) x A data frame, sp or sf object returned from get_census or similar. Value A data frame with a column variable containing the truncated variable name, and a column label describing it. # Query census data with truncated labels: label_data <- get_census(dataset='ca16', regions=list(cma="59933"), vectors=c("v_ca16_408","v_ca16_409","v_ca16_410"), level='csd', geo_format = "sf", labels="short")

list_census_datasets 7 # Get details for truncated vectors: label_vectors(label_data) list_census_datasets Query the CensusMapper API for available datasets. Query the CensusMapper API for available datasets. list_census_datasets(use_cache = FALSE, quiet = FALSE) use_cache quiet If set to TRUE, data will be read from a local cache, if available. If set to FALSE (the default), query the API for the data, and refresh the local cache with the result. When TRUE, suppress messages and warnings. Value Returns a data frame with a column dataset containing the code for the dataset, and a column description describing it. # List available datasets in CensusMapper list_census_datasets() list_census_regions Query the CensusMapper API for available regions in a given dataset. Query the CensusMapper API for available regions in a given dataset. list_census_regions(dataset, use_cache = FALSE, quiet = FALSE)

8 list_census_vectors dataset use_cache quiet The dataset to query for available regions, e.g. "CA16". If set to TRUE, data will be read from a local cache, if available. If set to FALSE (the default), query the API for the data, and refresh the local cache with the result. When TRUE, suppress messages and warnings. Value Returns a data frame with the following columns: region The region identifier. name The name of that region. level The census aggregation level of that region. pop The population of that region. municipal_status Additional identifiers to distinguish the municipal status of census subdivisions. CMA_UID The identifier for the Census Metropolitan Area the region is in (if any). CD_UID The identifier for the Census District the region is in (if any). PR_UID The identifier for the Province the region is in (if unique). list_census_regions('ca16') list_census_vectors Query the CensusMapper API for available vectors for a given dataset. Query the CensusMapper API for available vectors for a given dataset. list_census_vectors(dataset, use_cache = FALSE, quiet = TRUE) dataset use_cache quiet The dataset to query for available vectors, e.g. "CA16". If set to TRUE, data will be read from a local cache, if available. If set to FALSE (the default), query the API for the data, and refresh the local cache with the result. When FALSE, shows messages and warnings. Set to TRUE by default.

parent_census_vectors 9 Value Returns a data frame detailing the available Census vectors (i.e. variables) for a given Census dataset. This data frame has columns vector containing the short code for the variable, type describing whether it s a female, male, or total aggregate, label indicating the name of the variable, units indicating whether the value represents a numeric integer, percentage, dollar figure, or ratio, parent_vector to show hierarchical relationship, aggregation indicating whether the value is additive or a transformation, and a column details with a detailed description of the variable generated by traversing all labels within its hierarchical structure. # List all vectors for a given Census dataset in CensusMapper list_census_vectors('ca16') parent_census_vectors List all parent variables from vector hierarchical based on a (sub- )list of census variables returned by list_census_vectors or search_census_vectors. List all parent variables from vector hierarchical based on a (sub-)list of census variables returned by list_census_vectors or search_census_vectors. parent_census_vectors(vector_list) vector_list The list of vectors to be used library(dplyr, warn.conflicts = FALSE) list_census_vectors("ca16") %>% filter(vector == "v_ca16_4092") %>% parent_census_vectors()

10 search_census_vectors search_census_regions Query the CensusMapper API for regions with names matching a searchterm. Query the CensusMapper API for regions with names matching a searchterm. search_census_regions(searchterm, dataset, level = NA,...) searchterm dataset level The term to search for e.g. "Victoria". Search terms are case insensitive. If unable to find a given search term, this function will suggest the correct spelling to use when possible. The dataset to query for available regions, e.g. "CA16". One of NA, 'C', 'PR', 'CMA', 'CD', or 'CSD'. If specified, only return variables of specified level.... Further arguments passed on to list_census_regions. search_census_regions('victoria', 'CA16') # This will return a warning that no match was found, but will suggest similar named regions. search_census_regions('victorea', 'CA16') # This will limit region results to only include CMA level regions search_census_regions('victoria', 'CA16', level = "CMA") search_census_vectors Query the CensusMapper API for vectors with descriptions matching a searchterm. Query the CensusMapper API for vectors with descriptions matching a searchterm. search_census_vectors(searchterm, dataset, type = NA,...)

search_census_vectors 11 searchterm dataset type The term to search for e.g. "Ojibway". Search terms are case insensitive. If unable to find a given search term, this function will suggest the correct spelling to use when possible. The dataset to query for available vectors, e.g. "CA16". One of NA, 'Total', 'Male' or 'Female'. If specified, only return variables of specified type.... Further arguments passed on to list_census_vectors. search_census_vectors('ojibway', 'CA16') # This will return a warning that no match was found, but will suggest similar terms. search_census_vectors('ojibwe', 'CA16', 'Total')

Index Topic api get_census, 4 Topic canada get_census, 4 Topic census get_census, 4 Topic data get_census, 4 as_census_region_list, 2 census_vectors, 3 child_census_vectors, 4 get_census, 2, 4 get_census_geometry (get_census), 4 label_vectors, 6 list_census_datasets, 7 list_census_regions, 2, 5, 7, 10 list_census_vectors, 5, 8, 11 parent_census_vectors, 9 search_census_regions, 10 search_census_vectors, 10 sf, 5 SpatialPolygonsDataFrame, 5 12