View source: R/bfs_get_sse_data.R
| bfs_get_sse_data | R Documentation |
Deprecated since BFS 0.8.0: use bfs_sse_data() instead. It downloads the
data faster and stops on a query that wouldn't filter the data. This
function still works and gets only bug fixes, e.g. the labels of codes
with no name in language (see NEWS). To move your code, see the article
Moving to the new Swiss Stats Explorer functions.
Download a dataset of the Swiss Stats Explorer (SSE) API
(https://stats.swiss/). Select the data you need with query, built
from the codelists of bfs_get_sse_metadata().
bfs_get_sse_data(
number_bfs,
language = "de",
start_period = NULL,
end_period = NULL,
query = NULL,
column_name_type = "code",
variable_value_type = "text",
clean_names = FALSE
)
number_bfs |
The id of an SSE dataset (dataflow), e.g. |
language |
Language of the labels: |
start_period, end_period |
Optional first and last period of the data,
e.g. |
query |
A named list: the names are dimension codes (column |
column_name_type |
Column names as dimension |
variable_value_type |
Values as |
clean_names |
If |
The list of the SSE datasets is cached for the R session. A long-running
R session, e.g. a Shiny app, keeps using the version of a dataset it saw
first: call bfs_clear_cache() to use a new version, or use
bfs_sse_data(), which caches nothing.
A tibble with one column per dimension and the observations in
the value column. Returns NULL if there is no internet connection.
Marius Hodel
bfs_sse_data(), bfs_get_sse_metadata()
bfs_get_sse_data(
number_bfs = "DF_PASTA_552_MONTHLY",
language = "en",
query = list(
FREQ = "M",
ACCOMMODATION_TYPE = "552001",
COUNTRY_ORIGIN = c("CH", "AUSL")
),
start_period = "2020",
end_period = "2023"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.