Skip to content

About

ISO 4217 currency codes with minor units for R

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

isocurrencies

isocurrencies provides the ISO 4217 currency codes with their numeric codes, names and minor units, and helpers to check codes and round amounts. The data is ISO 4217 list one as SIX, the maintenance agency of the standard, publishes it. The package has no dependencies.

Installation

Using rpx:

rpx add isocurrencies

Using base R, from a downloaded GitHub release:

R CMD INSTALL isocurrencies_<version>.tar.gz

Usage

library(isocurrencies)

ISO_4217[ISO_4217$Letter == "KWD", ]
#>    Letter Numeric      Currency Minor_Units
#> 76    KWD     414 Kuwaiti Dinar           3

is_iso_currency(c("EUR", "GBp"))
#> [1]  TRUE FALSE

assert_iso_currency(c("EUR", "GBp", "LOC"))
#> Error: Not an ISO 4217 currency code: GBp, LOC

iso_currency_minor_units(c("EUR", "JPY", "XAU"))
#> [1]  2  0 NA

round_to_minor_units(c(2.675, 1234.5, 10.123456), c("EUR", "JPY", "XAU"))
#> [1]    2.68000 1235.00000   10.12346

Codes are case-sensitive: the pence code GBp is not GBP. round_to_minor_units() rounds half up, away from zero, unlike round(). Codes that are not cash, such as gold (XAU), have no minor units, and their amounts stay unrounded.

Updating the data

A weekly workflow compares data-raw/ISO_4217.csv with the list SIX publishes and fails when they differ. To update, run from the package root:

python3 data-raw/iso_4217.py
Rscript data-raw/build_data.R

Then review the diff of data-raw/ISO_4217.csv, update the date in R/data.R, run roxygen2::roxygenise(), and release a new version.

GitHub releases

Pushing a tag matching the version in DESCRIPTION (for example, v0.1.0) builds the source package and publishes a GitHub Release with the archive isocurrencies_<version>.tar.gz and SHA256SUMS. The package has no compiled code, so the source archive installs on every platform.

About

ISO 4217 currency codes with minor units for R

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages