inst/doc/statcan_attribute_files.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  message = FALSE, 
  warning = FALSE,
  comment = "#>",
  eval = nzchar(Sys.getenv("COMPILE_VIG"))
)

## ----setup--------------------------------------------------------------------
library(cancensus)
library(dplyr)

## -----------------------------------------------------------------------------
attributes <- get_statcan_geographic_attributes("2021")

attributes %>% colnames()

## -----------------------------------------------------------------------------
attributes %>%
  filter(CMATYPE_RMRGENRE %in% c("B","K")) |> # filter areas not in CTs
  group_by(CTCODE_SRCODE,CMATYPE_RMRGENRE) |>
  summarise(`Number of municipalities`=length(unique(CSDUID_SDRIDU)),.groups="drop") |>
  count(`Number of municipalities`,CMATYPE_RMRGENRE) |>
  arrange(CMATYPE_RMRGENRE,`Number of municipalities`)

Try the cancensus package in your browser

Any scripts or data that you put into this service are public.

cancensus documentation built on Oct. 5, 2023, 5:08 p.m.