knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of cbsodata4 is allowing access to the Open Data API v4 of Statistics Netherlands.
It is the successor of R package cbsodataR.
It uses the new / more efficient OData4 API
The download storage is faster (using data.table
)
It offers a familiar wide data format for users (cbs4_get_data
) as well as the default long format (cbs4_get_observations
).
At the moment only a development version can be installed from GitHub with:
# install.packages("devtools") devtools::install_github("statistiekcbs/cbsodata4")
library(cbsodata4)
Retrieve a list of all CBS / Statistics Netherlands tables with cbs4_get_datasets
:
# download the set of datasets datasets <- cbs4_get_datasets() datasets[1:5, c("Identifier", "Title")]
Get metadata of table <Identifier>
(e.g. 60006) with cbs4_get_metadata
:
meta <- cbs4_get_metadata(id="60006") print(meta) meta$Properties$Title # topics / measures meta$MeasureCodes[,c("Identifier", "Title")] # dimensions meta$Dimensions[, c("Identifier", "Title")]
Retrieve data with cbs4_get_data
:
# wide format, each measure its own column data <- cbs4_get_data("60006") head(data[, 1:4])
or cbs4_get_observations
# long format, one Value column obs <- cbs4_get_observations("60006") head(obs)
Add labels to a dataset with cbs4_add_label_columns
:
data <- cbs4_add_label_columns(data) head(data[,1:5]) obs <- cbs4_add_label_columns(obs) head(obs)
Find non-standard CBS catalogs with cbs4_get_catalogs
:
catalogs <- cbs4_get_catalogs() catalogs[,c("Identifier", "Title")]
For more information see vignette("cbsodata4")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.