| Type: | Package | 
| Version: | 0.2.1 | 
| Title: | Get Data from the 'KOF Datenservice' API | 
| Description: | Read Swiss time series data from the 'KOF Data' API, https://datenservice.kof.ethz.ch. The API provides macro economic time series data mostly about Switzerland. The package itself is a set of wrappers around the 'KOF Datenservice' API. The 'kofdata' package is able to consume public information as well as data that requires an API token. | 
| Depends: | R (≥ 3.0.0), jsonlite (≥ 1.1), httr | 
| Imports: | xts, zoo, | 
| Suggests: | tstools, rmarkdown, testthat | 
| URL: | https://github.com/KOF-ch/kofdata | 
| BugReports: | https://github.com/KOF-ch/kofdata/issues | 
| Date: | 2024-01-05 | 
| License: | GPL-2 | 
| RoxygenNote: | 7.2.3 | 
| Encoding: | UTF-8 | 
| NeedsCompilation: | no | 
| Packaged: | 2024-02-02 21:09:48 UTC; mbannert | 
| Author: | Matthias Bannert [aut, cre], Oliver Müller [aut], Severin Thoeni [aut], Diana Diaz [ctb] | 
| Maintainer: | Matthias Bannert <bannert@kof.ethz.ch> | 
| Repository: | CRAN | 
| Date/Publication: | 2024-02-03 13:50:02 UTC | 
Vector of Swiss cantons
Description
Vector of Swiss cantons
Usage
cantons(full = F)
Arguments
| full | logical full names or two letter classification. defaults to FALSE. | 
get_dataset
Description
Download a predefined set of time series.
Usage
download_cached_file(username, api_key, file_to_download, target = NULL)
Arguments
| username | Your dataservice user name | 
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
| file_to_download | The name of the file to retrieve. | 
| target | Path to the location, at which to store the file. If NULL, the file will be saved to the working directory. | 
Examples
f <-  download_cached_file("kofdatapkg", "313984fcd9f343d3961891319b0ed321",
"empty.txt",file.path(tempdir(),"empty.txt"))
Download Pre-Defined collection
Description
Download a predefined collection of time series.
Usage
get_collection(collection_name, api_key = NULL, show_progress = FALSE)
Arguments
| collection_name | The name of the collection you wish to download. For a list of available collections, go to ["list_available_collections"] | 
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
| show_progress | If collection to true, shows a progress bar of the data being downloaded. | 
Examples
get_collection("ds_kmi_mixed_freq",show_progress = TRUE)
Download Pre-Defined Dataset
Description
This function is deprecated. Use get_collection instead.
Download a predefined set of time series.
Usage
get_dataset(set_name, api_key = NULL, show_progress = FALSE)
Arguments
| set_name | The name of the set you wish to download. For a list of available sets, go to ["list_available_sets"] | 
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
| show_progress | If set to true, shows a progress bar of the data being downloaded. | 
Get a Former Time Series Identifier from KOF Database
Description
Get legacy keys given new time series keys. Note that not all records need to have a legacy key because there are more new keys than old keys.
Usage
get_legacy_key(ts_keys)
Arguments
| ts_keys | A vector of time series keys | 
Value
A named list of legacy keys
Get Localized Meta Information
Description
Download metadata given a time series key.
Usage
get_metadata(ts_keys, locale = c("en", "de", "fr", "it"))
Arguments
| ts_keys | A vector of time series keys. | 
| locale | character ISO-2-digit language of requested metadata. Meta data are for survey related typically available in English, German, French and Italian. Non survey data are not provided with meta information, yet. | 
Value
A named list of lists containing metadata.
Examples
get_metadata("kofbarometer","en")
Check Remaining Quota
Description
Query the API for the number of time series downloads remaining in the current month.
Usage
get_remaining_quota(api_key)
Arguments
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
Examples
get_remaining_quota("313984fcd9f343d3961891319b0ed321")
Get Time Series form KOF Datenservice API
Description
Download time series data from the KOF web API.
Usage
get_time_series(ts_keys, api_key = NULL, show_progress = FALSE)
Arguments
| ts_keys | A vector of timeseries keys | 
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
| show_progress | If set to true, shows a progress bar of the data being downloaded. year-month-day, otherwise only year and month. | 
Examples
get_time_series("kofbarometer")
List Available collection Names and Their Description
Description
collections are pre-defined lists of time series. collections are the convenient alternative to concatenating many series in an URL.
Usage
list_available_collections(api_key = NULL)
Arguments
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
Value
A data frame with the names, descriptions and public availability of collections. These collections can be downloaded via get_collection.
Examples
list_available_collections()
List Available Set Names and Their Description
Description
This function is deprecated. Use list_available_collections instead.
Sets are pre-defined lists of time series. Sets are the convenient alternative to concatenating many series in an URL.
Usage
list_available_sets(api_key = NULL)
Arguments
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
Value
A data frame with the names, descriptions and public availability of datasets. These sets can be downloaded via get_dataset.
Show Cached Files of Specific User
Description
Some users get individually composed, cached files. If you ordered such a service you can list all files available to you.
Usage
list_cached_files(username, api_key)
Arguments
| username | Your dataservice user name | 
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
Examples
available_files <- list_cached_files("kofdatapkg",
"313984fcd9f343d3961891319b0ed321")
available_files
List All Keys in a Collection
Description
List the keys of all time series in a collection. To learn more about specific keys, use get_metadata.
Usage
list_keys_in_collection(collectionname, api_key = NULL)
Arguments
| collectionname | The name of the collection | 
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
Value
If a single collection name is provided, a vector of time series keys. If multiple collection names are provided, a list of vectors of time series keys.
Examples
list_keys_in_collection("ds_kmi_mixed_freq")
List All Keys in a Set
Description
List the keys of all time series in a set. To learn more about specific keys, use get_metadata.
Usage
list_keys_in_set(setname, api_key = NULL)
Arguments
| setname | The name of the set | 
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
Value
If a single set name is provided, a vector of time series keys. If multiple set names are provided, a list of vectors of time series keys.
List Keys for All Publicly Available Time Series
Description
This function will be removed from future versions of kofdata.
Usage
list_public_keys()
Value
An array of all public time series keys.
Common parameters
Description
Common parameters
Arguments
| api_key | character Your API key. An API key is needed if accessing non-public timeseries. If downloading public timeseries parameter can be omitted. | 
translate_legacy_keys
Description
Gives ts_keys for the given legacy keys.
Usage
translate_legacy_keys(legacy_keys, chunksize = 100)
Arguments
| legacy_keys | A vector of legacy keys for which to find new keys | 
| chunksize | integer to set chunksize in order to avoid URLs that are too long. | 
Value
A list of vectors of new ts_keys