| bfs_get_data | R Documentation |
Download a dataset from the PXWeb API of the BFS with its BFS number.
Find the BFS number with bfs_get_catalog_data() or on the BFS website.
bfs_get_data(
number_bfs,
language = "de",
query = NULL,
column_name_type = "text",
variable_value_type = "text",
clean_names = FALSE,
delay = NULL
)
number_bfs |
The BFS number of a dataset, e.g.
|
language |
Language of the dataset: |
query |
Optional selection of the data: a named list with the
variable codes as names and the value codes as values (columns |
column_name_type |
Column names as |
variable_value_type |
Values as |
clean_names |
If |
delay |
Optional number of seconds to wait before downloading the data, to avoid "Too Many Requests" errors when calling the API in a loop. |
Large datasets can exceed the limits of the API: select only the data you
need with query, or download the whole file with bfs_download_asset().
The PXWeb API is the API of STAT-TAB, which the BFS is replacing with the
Swiss Stats Explorer: check first if the statistic is on
https://stats.swiss/ and use bfs_sse_data().
A tibble. Returns NULL if there is no internet connection.
bfs_get_catalog_data(), bfs_get_metadata(),
bfs_get_data_comments()
# whole dataset
bfs_get_data(number_bfs = "px-x-1502040100_131", language = "en")
# only some years and levels of study
bfs_get_data(
number_bfs = "px-x-1502040100_131",
language = "en",
query = list(Jahr = c("40", "41"), Studienstufe = c("2", "3"))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.