Package 'CheckDigit'

Title: Calculate and Verify Check Digits
Description: Check digits are used like file hashes to verify that a number has been transcribed accurately. The functions provided by this package help to calculate and verify check digits according to various algorithms.
Authors: Justin Brantley [aut, cre]
Maintainer: Justin Brantley <[email protected]>
License: GPL (>= 3)
Version: 1.0.0
Built: 2025-03-10 03:02:40 UTC
Source: https://gitlab.com/fascinatingfingers/checkdigit

Help Index


Append a check digit to a value

Description

Append a check digit to a value

Usage

AppendCheckDigit(x, method)

Arguments

x

character vector of values requiring a check digit

method

a character value naming the check digit algorithm to use

Value

character vector similar to x but with a check digit appended to each value

Examples

AppendCheckDigit("1234", "Verhoeff") # 12340

Verhoeff algorithm implementation

Description

The Verhoeff algorithm is appropriate for numerical data and detects all single-digit substitutions (x to y) and adjacent digit transpositions (xy to yx). In addition, the Verhoeff check digit can detect most twin errors (xx to yy), jump twin errors (xyx to zyz), jump transpositions (xyz to zyx), and phonetic errors ("sixty" to "sixteen").

Usage

AppendCheckDigit.Verhoeff(x)

VerifyCheckDigit.Verhoeff(x)

Arguments

x

character vector of values

References

Verhoeff, J. "Error Detecting Decimal Codes", Mathematical Centre Tract 29, The Mathematical Centre, Amsterdam, 1969.


Verify whether a value ends with a valid check digit

Description

Verify whether a value ends with a valid check digit

Usage

VerifyCheckDigit(x, method)

Arguments

x

character vector of values to verify

method

a character value naming the check digit algorithm to use

Value

logical vector the same length as x

Examples

VerifyCheckDigit("12340", "Verhoeff")  # TRUE
VerifyCheckDigit("21340", "Verhoeff")  # FALSE
VerifyCheckDigit("13240", "Verhoeff")  # FALSE
VerifyCheckDigit("12430", "Verhoeff")  # FALSE
VerifyCheckDigit("12304", "Verhoeff")  # FALSE