knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Statcanopener provides a lightweight wrapper for Statistics Canada's Web Data Service. With it, you can build Statcan's API queries into your packages, reporting workflows or Shiny apps.
(Do not use API between 12:00 midnight and 8:30AM EST lol.)
You can install the development version of statcanopener from github with:
# install.packages("remotes") remotes::install_github("tweed1e/statcanopener")
This is a basic example which shows you how to solve a common problem:
library(statcanopener) # Get metadata for product ID 35100003 result <- getCubeMetadata(35100003) # returns httr response object content <- httr::content(result) # extract content of response str(content[[1]], max.level = 2)
This package was inspired by the cansim package, which includes this functionality and much more. This is intended to be a bare bones, non-opinionated wrapper for the web data service, rather than a full-fledged end-user API access package. (E.g., this won't have a function to automatically scale from millions of $ to $.)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.