Title: | Calculate and Verify Check Digits |
Version: | 1.0.0 |
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. |
License: | GPL (≥ 3) |
URL: | https://fascinatingfingers.gitlab.io/checkdigit, https://gitlab.com/fascinatingfingers/checkdigit |
BugReports: | https://gitlab.com/fascinatingfingers/checkdigit/-/issues |
Suggests: | spelling, testthat |
Encoding: | UTF-8 |
Language: | en-US |
RoxygenNote: | 7.1.2 |
NeedsCompilation: | no |
Packaged: | 2022-04-24 05:29:06 UTC; rstudio |
Author: | Justin Brantley [aut, cre] |
Maintainer: | Justin Brantley <fascinatingfingers@icloud.com> |
Repository: | CRAN |
Date/Publication: | 2022-04-24 14:30:17 UTC |
CheckDigit: 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.
Author(s)
Maintainer: Justin Brantley fascinatingfingers@icloud.com
See Also
Useful links:
Report bugs at https://gitlab.com/fascinatingfingers/checkdigit/-/issues
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
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
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.