| Type: | Package | 
| Title: | Implementation of the 'Verhoeff' Check Digit Algorithm | 
| Version: | 0.4.0 | 
| Author: | Conor Neilson | 
| Maintainer: | Conor Neilson <condwanaland@gmail.com> | 
| Description: | An implementation of the 'Verhoeff' algorithm for calculating check digits (Verhoeff, J. (1969) <doi:10.1002/zamm.19710510323>). Functions are provided to calculate a check digit given an input number, calculate and append a check digit to an input number, and validate that a check digit is correct given an input number. | 
| License: | GPL-3 | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| RoxygenNote: | 7.1.1 | 
| Suggests: | testthat, dplyr | 
| NeedsCompilation: | no | 
| Packaged: | 2021-01-22 21:25:33 UTC; conorneilson | 
| Repository: | CRAN | 
| Date/Publication: | 2021-01-26 12:20:02 UTC | 
calculate_digit
Description
Calculates a single Verhoeff Check Digit. This function is exported, but it would usually be called from one of the 'verhoeff_*' wrapper functions
Usage
calculate_digit(number, d5, d5_p, inv_v)
Arguments
| number | A number you want to calculate the check digit for | 
| d5 | The verhoeff d5 matrix. Retrievable with create_verhoeff_matrices()$d5 | 
| d5_p | The verhoeff p matrix. Retrievable with create_verhoeff_matrices()$d5_p | 
| inv_v | The verhoeff inv matrix. Retrievable with create_verhoeff_matrices()$inv_v | 
Value
A single integer
Examples
dat <- verhoeff::create_verhoeff_matrices()
calculate_digit(5, dat$d5, dat$d5_p, dat$inv_v)
create_verhoeff_matrices
Description
create_verhoeff_matrices
Usage
create_verhoeff_matrices()
Value
An object with three fields; d5, d5_p, and inv_v
Examples
verhoeff::create_verhoeff_matrices()$d5
verhoeff::create_verhoeff_matrices()$d5_p
verhoeff::create_verhoeff_matrices()$inv_v
prepare_number
Description
Takes a number and prepares it for input to the verhoeff algorithim by reversing it
Usage
prepare_number(number)
Arguments
| number | A single number that can be coerced to numeric | 
Value
A numeric vector of length equal to number of digits in the input
Examples
prepare_number(1234)
verhoeff_append
Description
Return a number with its check digit appended
Usage
verhoeff_append(number, sep = "-")
Arguments
| number | The number to calculate a check digit for | 
| sep | A separator for the two numbers | 
Value
Numeric vector of length equal to its input
Examples
verhoeff::verhoeff_append(123)
verhoeff_calculate
Description
verhoeff_calculate
Usage
verhoeff_calculate(number, as_list = FALSE)
Arguments
| number | The vector of numbers you want a check digit for | 
| as_list | Return the results as a list? Defaults to false | 
Value
Vector or list of check digits
Examples
verhoeff_calculate(1234)
verhoeff_validate
Description
Enter a number, and an existing check digit. Function will return true if the supplied check digit is a correct verhoeff check digit for the given number
Usage
verhoeff_validate(number, check_digit)
Arguments
| number | A numerical input | 
| check_digit | An existing check digit for the input number | 
Value
Logical vector
Examples
verhoeff::verhoeff_validate(123, 3)