It's on CRAN - Introducing the kofdata R package

At KOF, we have recently introduced a REST Interface to conveniently automate data downloads. R users can now benefit from an even more convenient way to consume KOF data: the brand new ‘kofdata’ CRAN package. The package allows to download Swiss time series data and meta information through simple R functions.

Installing the package is a matter of:

install.packages("kofdata")

Once you have installed the package you can download data and obtain R time series objects with a simple function call. Get Switzerland’s most popular macro economic forward looking indicator, the KOF Barometer like this:

library(kofdata)
get_time_series("kofbarometer")

Because you will receive an R time series object you can easily create a time series plot out-of-the-box using base R’s plot. Or get our tstools package and given even neater plots…

## Loading required package: jsonlite
## Loading required package: httr
# base R alternative without additional plot packages
tslist <- get_time_series("kofbarometer")
plot(tslist$kofbarometer)


library(tstools)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
tsplot(tslist)

And yes, there’s a bit more to the package than just querying single time series. Here is a small overview of the current, basic functionality.

lsf.str("package:kofdata")
## cantons : function (full = F)  
## download_cached_file : function (username, api_key, file_to_download, target = NULL)  
## get_dataset : function (set_name, api_key = NULL, show_progress = FALSE)  
## get_legacy_key : function (ts_keys)  
## get_metadata : function (ts_keys, locale = c("en", "de", "fr", "it"))  
## get_remaining_quota : function (api_key)  
## get_time_series : function (ts_keys, api_key = NULL, show_progress = FALSE)  
## list_available_sets : function ()  
## list_cached_files : function (username, api_key)  
## list_keys_in_set : function (setname)  
## list_public_keys : function ()  
## start_key_explorer : function ()  
## translate_legacy_keys : function (legacy_keys, chunksize = 100)
Avatar
Matt Bannert
gut checks stack. makes public data public. runs on rap & open source.

I am interested in data science devOps for official statistics, open source, time series, rstats, Python and SQL. I contribute to RAdwords, tstools, timeseriesdb and kofdata.