| Title: | Switzerland's Data Series in One Place |
|---|---|
| Description: | Download and import open Swiss economic time series from 'dataseries.org' <https://dataseries.org>, a comprehensive and up-to-date collection of public data from Switzerland. Series are retrieved through the public 'dataseries.org' API and imported as a 'data.frame' or 'ts' object. |
| Authors: | Christoph Sax [aut, cre], Jannes Muenchow [ctb] |
| Maintainer: | Christoph Sax <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.0 |
| Built: | 2026-06-03 13:19:51 UTC |
| Source: | https://github.com/cynkra/dataseries |
Everything downloaded from dataseries.org is cached
in memory for the lifetime of the R session. cache_ls() lists the cached
objects (keyed by request URL); cache_rm() empties the cache, which forces
the next call to download fresh data.
cache_ls() cache_rm()cache_ls() cache_rm()
cache_ls() returns a character vector of cache keys; cache_rm()
is called for its side effect and returns NULL invisibly.
ds_catalog() cache_ls() cache_rm()ds_catalog() cache_ls() cache_rm()
ds() downloads open Swiss economic time series from
dataseries.org.
ds(dataset, ..., from = NULL, to = NULL, class = c("data.frame", "ts"))ds(dataset, ..., from = NULL, to = NULL, class = c("data.frame", "ts"))
dataset |
a single dataset |
... |
dimension filters, given as named arguments where each name is a
dimension of |
from, to
|
optional date bounds (a |
class |
class of the return value: |
Data on dataseries.org is organized into datasets. A dataset is a family
of related series and is, in most cases, a multi-dimensional cube: a single
time series is one cell of the cube, addressed by the dataset plus one code
per dimension. Pass those codes as named arguments (the names are the
dimension names, see ds_meta()):
ds("ch_seco_gdp", type = "real", structure = "gdp", seas_adj = "csa")
Dimension arguments are optional. Omit them and you get the whole dataset
(all series, in long format). A few datasets are a single series and take no
dimensions at all (e.g. ds("ch_kof_barometer")). Filtering happens on the
server, so selecting one series does not download the whole cube.
Downloads are cached in memory for the session. Run cache_rm() to force
a fresh download.
A data.frame or ts/mts object, or NULL if the selection is
empty.
ds_catalog() for the list of datasets and ds_meta() for a
dataset's dimensions.
# whole dataset (long data.frame) ds("ch_fso_cpi") # one series, by dimension code ds("ch_fso_cpi", item = "100_100") # several series, restricted to a date range ds("ch_fso_cpi", item = c("100_100", "100_1"), from = "2020-01-01") # as a ts object ds("ch_seco_gdp", type = "real", structure = "gdp", seas_adj = "csa", class = "ts")# whole dataset (long data.frame) ds("ch_fso_cpi") # one series, by dimension code ds("ch_fso_cpi", item = "100_100") # several series, restricted to a date range ds("ch_fso_cpi", item = c("100_100", "100_1"), from = "2020-01-01") # as a ts object ds("ch_seco_gdp", type = "real", structure = "gdp", seas_adj = "csa", class = "ts")
Lists every dataset available on dataseries.org,
one row per dataset. Use the id column with ds() to download data and
with ds_meta() to inspect a dataset's dimensions.
ds_catalog()ds_catalog()
A data.frame with one row per dataset and the columns id,
title, concept, topic, source, license, frequency, start,
end and n_series.
cat <- ds_catalog() head(cat) # search the catalog cat[grepl("price", cat$title, ignore.case = TRUE), c("id", "title")]cat <- ds_catalog() head(cat) # search the catalog cat[grepl("price", cat$title, ignore.case = TRUE), c("id", "title")]
Returns the full metadata for a single dataset: its dimensions, the codes
(levels) available within each dimension, labels, source, license and date
range. Use this to discover which dimension codes to pass to ds().
ds_meta(dataset)ds_meta(dataset)
dataset |
a single dataset |
A named list (the parsed metadata). Notable elements are dim_order
(the dataset's dimensions) and dimensions (each dimension's levels,
keyed by code, with a label).
m <- ds_meta("ch_seco_gdp") m$dim_order # "type", "structure", "seas_adj" names(m$dimensions$type$levels) # the codes you can pass as type = ...m <- ds_meta("ch_seco_gdp") m$dim_order # "type", "structure", "seas_adj" names(m$dimensions$type$levels) # the codes you can pass as type = ...
Returns a flat, searchable table of the individual series available across
every dataset on dataseries.org — one row per
series. This is the finest-grained way to discover what exists: grep it, or
pass a pattern to filter. The dataset, dim and code columns are
exactly what you feed back to ds().
ds_search(pattern = NULL)ds_search(pattern = NULL)
pattern |
optional search string, treated as a case-insensitive regular
expression and matched against the series |
A data.frame with the columns dataset, dataset_title,
frequency, dim, code, label and path.
ds_catalog() for the dataset-level list and ds_meta() for one
dataset's dimensions.
# everything ds_search() # find unemployment series, then download one hits <- ds_search("unemployment") head(hits) ds(hits$dataset[1], setNames(list(hits$code[1]), hits$dim[1]))# everything ds_search() # find unemployment series, then download one hits <- ds_search("unemployment") head(hits) ds(hits$dataset[1], setNames(list(hits$code[1]), hits$dim[1]))