% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ds.R
\name{ds}
\alias{ds}
\title{Download time series from dataseries.org}
\usage{
ds(dataset, ..., from = NULL, to = NULL, class = c("data.frame", "ts"))
}
\arguments{
\item{dataset}{a single dataset \code{id}, as listed by \code{\link[=ds_catalog]{ds_catalog()}}.}

\item{...}{dimension filters, given as named arguments where each name is a
dimension of \code{dataset} and each value is one or more codes, e.g.
\code{type = "real"} or \code{structure = c("gdp", "gva")}. A single named list may be
passed instead, which is convenient programmatically (e.g. from the output
of \code{\link[=ds_search]{ds_search()}}). See \code{\link[=ds_meta]{ds_meta()}} for the available dimensions and codes.}

\item{from, to}{optional date bounds (a \code{Date} or an ISO \code{"YYYY-MM-DD"}
string) that restrict the returned range, inclusive.}

\item{class}{class of the return value: \code{"data.frame"} (the default, one row
per observation in long format) or \code{"ts"}. For \code{"ts"} the selected series
are laid out as columns, one per cell. (To obtain an \pkg{xts} object,
wrap the result: \code{xts::as.xts(ds(..., class = "ts"))}.)}
}
\value{
A \code{data.frame} or \code{ts}/\code{mts} object, or \code{NULL} if the selection is
empty.
}
\description{
\code{ds()} downloads open Swiss economic time series from
\href{https://dataseries.org}{dataseries.org}.
}
\details{
Data on dataseries.org is organized into \strong{datasets}. A dataset is a family
of related series and is, in most cases, a multi-dimensional \emph{cube}: a single
time series is one cell of the cube, addressed by the dataset plus one code
per dimension. Pass those codes as \strong{named arguments} (the names are the
dimension names, see \code{\link[=ds_meta]{ds_meta()}}):

\if{html}{\out{<div class="sourceCode r">}}\preformatted{ds("ch_seco_gdp", type = "real", structure = "gdp", seas_adj = "csa")
}\if{html}{\out{</div>}}

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. \code{ds("ch_kof_barometer")}). Filtering happens on the
server, so selecting one series does not download the whole cube.

Downloads are \strong{cached in memory} for the session. Run \code{\link[=cache_rm]{cache_rm()}} to force
a fresh download.
}
\examples{
\dontrun{
# 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")
}
}
\seealso{
\code{\link[=ds_catalog]{ds_catalog()}} for the list of datasets and \code{\link[=ds_meta]{ds_meta()}} for a
dataset's dimensions.
}
