Financial Functions & More

This fills the gaps credit analysts and loan modellers at Optimum Credit identify in the existing R code body. It allows for the production of documentation with less coding, replicates a number of Microsoft Excel functions useful for modelling loans (without rounding), and other helpful functions for producing charts and tables. It also has some additional scales for use, including a GBP scale.


Build Status Coverage Status CRAN downloads optiRum is a growing package of utilities created by Optimum Credit Ltd's analysts. It is designed to provide convenience functions, standards, and useful snippets. Optimum Credit derives significant value from the R platform and associated community, so non-commercially sensitive functionality is made available in the spirit of reciprocity.


The lastest stable version (0.37.1) of the package is available on CRAN, and you can get the latest development version by running:


Financial calcs

We have a range of financial functions that follow the Excel conventions. More of these will be released upon request (by emailing the package author) or as they are required by Optimum analysts

  • PV -- present value
  • PMT -- instalment
  • RATE -- interest rate
  • APR -- produces the annual compound rate needed for UK financial services

Tax calcs (NEW)

As we've been doing more on calculating income and expenditure, we have included some generic functions that help calculate values for the UK tax system

  • taxYear provides the year that a date would belong to. It can be overridden to use any tax year, but this provides a means for moving between changing tax values over time
  • calcNetIncome gives the ability to calculate UK net income figures based off personal circumstances and tax tables

Credit scoring / logistic regressions

There are functions for credit analysts and people dealing with logistic regressions:

  • the logit, odds and probability functions enable the conversion from logit to probability, vice versa and anywhere in between -- great for handling glm outputs
  • scaledScore -- this produces the scores that companies are used to working with for the assessment of credit quality
  • giniChart and giniCoef -- produces a Gini chart in keeping with the Optimum style and embeds the coefficient, whilst the standalone giniCoef function allows for extracting a value or a series of values for use


There are helper functions that reduce document development time:

  • sanitise -- handles special characters for LaTeX documents, including situations where you have unresolved square brackets at the beginning which is great if you've used cut2 and want to show summary stats for intervals
  • generatePDF -- allows the production of PDFs in a one-liner
  • multiplot -- allows the plotting of multiple charts into one area, primarily of benefit when producing figures for documents
  • pounds -- displays values with a UK pound symbol at the front with UK decimalisation practices, this extends scales
  • thousands -- displays values to the nearest thousand and in a condensed format that is ideal for charts, this extends scales
  • theme\_optimum -- this produces a good looking frame for charts
  • convertToXML -- a lot of people are concerned about getting data out of XML, but it's difficult to find functions that put output data in XML, so this function takes XML functionality and wraps it neatly for such cases
  • CJ.dt -- a cross-join function for two data.tables


optiRum 0.40.1


  • Better website


  • New tax year data
  • Improved vignettes
  • Compatability with latest ggplot2 version

optiRum 0.37.3


  • Made theme_optimum() backwards compatible

optiRum 0.37.2


  • Changes for ggplot2 2.0.0

optiRum 0.37.1


  • Changes for latest CRAN policies

optiRum 0.36


  • new function to calcIncomeTax for borrowers


  • Changes for latest CRAN policies

optiRum 0.35


  • Added wordwrap formatter for splitting a string over multiple lines for chart axis


  • Improved/overhauled theme_optimum()


  • Improved package metadata and function's use of other packages

optiRum 0.34


  • Added fv argument to PV, RATE, and APR

Bug fixes:

  • Added space after \pounds in sanitise to allow for people putting £m etc

optiRum 0.33


  • Added function convertToXML for putting a data table into XML
  • Added function CJ.dt to cross-join two data.tables

optiRum 0.32

Bug fixes:

  • Removed use of ~\ in generatePDF tests that was violating CRAN policies
  • Removed reference to AUC package in theme_optimum as it is not required

optiRum 0.31

Bug fixes:

  • Removed use of tempdir() in generatePDF tests that was causing CRAN Windows compilation issues

optiRum 0.30

Bug fixes:

  • Use of the data.table package was resulting in errors in generatePDF.
    Code has been amended to work under a new environment within the global package
  • The generatePDF function did not correctly pass ... to internal functions.
    This has now been changed, primarily for the benefit of being able to compile with xelatex etc


  • thousands has been created to provide a neater format for scales and presentations
  • pounds has been created to provide a neater format for scales and presentations

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.40.1 by Steph Locke, 3 years ago,

Report a bug at

Browse source code at

Authors: Steph Locke [aut, cre] , Locke Data [fnd] ( , Optimum Credit Ltd's analysts [fnd] ( , Maëlle Salmon [ctb]

Documentation:   PDF Manual  

GPL-3 license

Imports data.table, ggplot2, AUC, grid, knitr, plyr, scales, stringr, XML

Suggests testthat, covr, rmarkdown

Suggested by iemisc.

See at CRAN