cbsodataR-package: Download all data from Statistics Netherlands / CBS

cbsodataR-packageR Documentation

Download all data from Statistics Netherlands / CBS

Description

cbsodataR allows to download all official statistics of Statistics Netherlands (CBS) into R. For a introduction please visit the vignette: vignette("cbsodataR", package="cbsodataR"). For an introduction on using cbs cartographic maps: vignette("maps", package="cbsodataR") The functions cbs_get_datasets() and cbs_get_data() should get you going. Interested in cartographic maps, see cbs_get_maps().

Catalog function

  • cbs_get_datasets() returns a data.frame with table of contents (toc): the publication meta data for available tables, can also include the extra tables not directly available in StatLine (dataderden)

  • cbs_get_catalogs(), returns data.frame with the available (extra) catalogs.

  • cbs_get_toc(), returns a data.frame with table of contents (toc): the publication meta data for available tables within the standard CBS

  • cbs_search(), returns a data.frame with tables that contain the given search word.

Data retrieval

  • cbs_get_data(), returns the data of a specific opendata/StatLine table

  • cbs_download_table(), saves the data (and metadata) as csv files into a directory

Meta data

  • cbs_get_meta(), returns the meta data objects of a specific opendata / StatLine table .

  • cbs_add_date_column(), converts date/period codes into DateTime objects in the data set that was downloaded.

  • cbs_add_label_columns(), adds labels to the code columns in the data that was downloaded.

Cartographic maps

  • cbs_get_maps(), returns a data.frame with available CBS maps

  • cbs_join_sf_with_data(), returns an sf object joined with cbs table

  • cbs_get_sf(), returns an sf object without data, e.g. "gemeente_2020".

Specify different server

Besides the official CBS data, there are also third party and preview dataservices implementing the same protocol. The base_url parameter allows to specify a different server. The base_url can either be specified explicitly or set globally with with options(cbsodataR.base_url = "http://example.com"). Some further tweaking may be necessary for third party services, a download url is constructed using: either with:

  • ⁠<base_url>/<BULK>/<id>/...⁠ for data

  • ⁠<base_url>/<API>/<id>/?$format=json⁠ for metadata

Default values for BASEURL, BULK and API are set in the package options, but can be changed with:

options(
 cbsodataR.base_url = "https://opendata.cbs.nl",
 cbsodataR.BULK = "ODataFeed/odata",
 cbsodataR.API = "ODataAPI/odata"
)

which are the default values set in the package.

Copyright use

The content of CBS opendata is subject to Creative Commons Attribution (CC BY 4.0). This means that the re-use of the content is permitted, provided Statistics Netherlands is cited as the source. For more information see: https://www.cbs.nl/en-gb/about-us/website/copyright

Author(s)

Maintainer: Edwin de Jonge edwindjonge@gmail.com

Other contributors:

  • Sara Houweling [contributor]

See Also

Useful links:


edwindj/cbsodataR documentation built on Oct. 17, 2024, 3:35 a.m.