README.md

datahub

Overview

datahub is a wrapper for api.datahub.is, to access datasets in R.

Installation

# install.packages("devtools")
devtools::install_github("palmargisla/datahub-r")

I also recommend installing dplyr to more easily work with dataframes.

install.packages("dplyr")

Usage

library(dplyr)
library(datahub)

# If you have a datahub account you can login using
# login("email", "password")

datahub gives you access to 5 info functions

fetch_currency_info()
fetch_index_info()
fetch_interest_info()
fetch_commodity_info()
fetch_other_info()

you can also get a combined dataframe with all of them, thought of as a useful lookup table.

fetch_all_info() %>%
  filter(stringr::str_detect(name, 'neysluverð'))

if you just want information on all currencies, you can use this command

fetch_currency_info()
#     code            name source_code        source_name description                last_update                          usage
#1 USD-ISK Bandaríkjadalur          SI Seðlabanki Íslands             2019-04-11T04:47:45.650459 fetch_currency('USD-ISK','SI')
#2 DKK-ISK    Dönsk króna           SI Seðlabanki Íslands             2019-04-11T04:47:45.650459 fetch_currency('DKK-ISK','SI')
#3 EUR-ISK            Evra          SI Seðlabanki Íslands             2019-04-11T04:47:45.650459 fetch_currency('EUR-ISK','SI')
#4 JPY-ISK    Japanskt jen          SI Seðlabanki Íslands             2019-04-11T04:47:45.650459 fetch_currency('JPY-ISK','SI')
#5 CAD-ISK     Kanadadalur          SI Seðlabanki Íslands             2019-04-11T04:47:45.650459 fetch_currency('CAD-ISK','SI')
# ...

the last column of the dataframe, usage, gives you a code snippet that you can use to the dataset.

fetch_currency('USD-ISK','SI')
#     code source_code       date ask_rate bid_rate mid_rate
#1 USD-ISK          SI 2019-04-10   119.12   118.56   118.84
#2 USD-ISK          SI 2019-04-09   118.98   118.42   118.70
#3 USD-ISK          SI 2019-04-08   119.11   118.55   118.83
#4 USD-ISK          SI 2019-04-05   119.24   118.68   118.96
#5 USD-ISK          SI 2019-04-04   119.40   118.84   119.12
# ...

these functions take in optional query arguments, an example of this can be seen below. (The source code values that appear within parentheses, are values that have been bridged)

fetch_commodity('WTI', 'EIA', query = list(from = '2019-01-01', to = '2019-03-01', bridge = 'last'))
#  code source_code       date value               unit
#1  WTI       (EIA) 2019-01-01 45.15 Dollars per Barrel
#2  WTI         EIA 2019-01-02 46.31 Dollars per Barrel
#3  WTI         EIA 2019-01-03 46.92 Dollars per Barrel
#4  WTI         EIA 2019-01-04 47.76 Dollars per Barrel
#5  WTI       (EIA) 2019-01-05 47.76 Dollars per Barrel
# ...

# for addition information on extra parameters use
?fetch_commodity

If you are logged in, you can add a twitter or linkedin signature at the bottom of you chart

title

Use these commands to sign your last plot.

sign_chart(last_plot(), signature_side = 'left')
sign_chart(last_plot(), signature_side = 'right', signature = 'linkedin')

title

Help

If you need help, have any questions or need specific datasets, please contant palmar@datahub.is



palmargisla/datahub-r documentation built on Sept. 18, 2019, 9:50 p.m.