Skip to content

Convert various currencies into other currencies using the Fixer.io API.

License

Notifications You must be signed in to change notification settings

peterhurford/currencyr

Repository files navigation

CurrencyR

CurrencyR is a package for converting currencies into other currencies. It is backed by the Fixer.io API, a free JSON API for current and historical foreign exchange rates published by the European Central Bank.

You need a Fixer API key for this to work! Please go to http://fixer.io and sign up for a free API key. Then add export FIXER_KEY=apikeygoeshere to your ~/.bash_profile to use this service.

currency <- currencyr::convert(1000, from = "USD", to = "CAD")
currency
# 1302.8 Canadian Dollar
currency$value
# 1302.8
currency$exchange_rate
# 1.3028
currency$unit
# "Canadian Dollar"
currency$code
# "CAD"

You can also use past conversion rates from 1 Jan 2000 onward.

> currencyr::convert(1000, from = "USD", to = "CAD", as_of = "today")
[1] "1255.5 Canadian Dollar"
> currencyr::convert(1000, from = "USD", to = "CAD", as_of = "2012-01-01")
[1] "1021.3 Canadian Dollar"
> currencyr::convert(1000, from = "USD", to = "CAD", as_of = "2002-01-01")
[1] "1597.3 Canadian Dollar"

Installation

This package is not yet available from CRAN. To install the latest development builds directly from GitHub, run this instead:

if (!require("devtools")) install.packages("devtools")
devtools::install_github("peterhurford/currencyr")

About

Convert various currencies into other currencies using the Fixer.io API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages