bfs_get_metadata: Get the variables of a BFS dataset

View source: R/bfs_get_metadata.R

bfs_get_metadataR Documentation

Get the variables of a BFS dataset

Description

Get the variables of a dataset of the PXWeb API and the values each variable can take. Use them to build the query of bfs_get_data().

Usage

bfs_get_metadata(number_bfs, language = "de")

Arguments

number_bfs

The BFS number of a dataset, e.g. "px-x-1502040100_131".

language

Language of the dataset: "de" (default), "fr", "it" or "en".

Details

The PXWeb API is the API of STAT-TAB, which the BFS is replacing with the Swiss Stats Explorer (see bfs_sse_dimensions()).

Value

A tibble with one row per variable and the columns code and text (variable code and label), values and valueTexts (list columns with the value codes and labels) and title (title of the dataset). Use tidyr::unnest_longer(metadata, c(values, valueTexts)) to get one row per value. Returns NULL if there is no internet connection.

See Also

bfs_get_data()

Examples


metadata <- bfs_get_metadata(number_bfs = "px-x-1502040100_131", language = "en")
metadata

# one row per value
tidyr::unnest_longer(metadata, c(values, valueTexts))


BFS documentation built on Oct. 21, 2026, 1:07 a.m.