knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

cbsodata4

CRAN
status R build status AppVeyor build
status Codecov test coverage

The goal of cbsodata4 is allowing access to the Open Data API v4 of Statistics Netherlands.

It is the successor of R package cbsodataR.

Installation

At the moment only a development version can be installed from GitHub with:

# install.packages("devtools")
devtools::install_github("statistiekcbs/cbsodata4")

Usage

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")



statistiekcbs/cbsccb documentation built on April 8, 2022, 2:38 a.m.