The aim of the statsnz.odata package is to provide some helpful wrapper functions to retrieve data from the Stats NZ OData API.
It also powers a simple shiny app that shows what datasets are in the API and allows for some basic ordering, filtering etc. Click here to see the live version.
Install by:
devtools::install_github("xaviermiles/statsnz.odata")
Some examples of using API wrappers:
library(statsnz.odata)
set_secrets("subscription_key" = "<your key goes here>")
df_to_browse_data <- get_catalogue()
covid_indicators_metadata <- basic_get("Covid-19Indicators", "Resources")
nzac_data <- basic_get(
"Covid-19Indicators", "Observations",
query = paste0(
"$filter=ResourceID eq 'CPACT12' and Label1 eq 'New Zealand Activity Index (NZAC)'",
"&$orderby=Period"
)
)
employ_metadata <- basic_get("EmploymentIndicators", "Resources")
employ_row_counts <- basic_get(
"EmploymentIndicators", "Observations",
query = "$apply=groupby((ResourceID),aggregate($count as count))"
)
Please note that the statsnz.odata project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.