Learn R Programming

libbib (version 1.6.4)

get_isbn_13_check_digit: Get ISBN 13 check digit

Description

Takes a string representation of an ISBN 13 and returns the check digit that satisfies the necessary condition. It can take a 13 digit string (and ignore the already extant check digit) or a 12 digit string (without the last digit)

Usage

get_isbn_13_check_digit(x, allow.hyphens = FALSE, errors.as.nas = FALSE)

Value

Returns the character check digit that satifies the mod 10 condition. Returns NA if input is NA

Arguments

x

A string of 12 or 13 digits

allow.hyphens

A logical indicating whether the hyphen separator should be allowed (default is FALSE)

errors.as.nas

return NA if error instead of throwing error (default is FALSE)

Examples

Run this code

get_isbn_13_check_digit("9780306406157")

# 12 digit string
get_isbn_13_check_digit("978030640615")

get_isbn_13_check_digit("onetwothreefo", errors.as.nas=TRUE)  # NA

# vectorized
get_isbn_13_check_digit(c("9780306406157", "9783161484100"))

Run the code above in your browser using DataLab