is_isbn_code: Does the character vector contain ISBN book codes?

Description Usage Arguments Value Examples

Description

Checks that the input contains ISBN-10 or ISBN-13 book codes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
assert_all_are_isbn_codes(x, type = c("10", "13"), na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

assert_any_are_isbn_codes(x, type = c("10", "13"), na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop"))

is_isbn10_code(x, .xname = get_name_in_parent(x))

is_isbn13_code(x, .xname = get_name_in_parent(x))

is_isbn_code(x, type = c("10", "13"))

Arguments

x

Input to check.

type

Either "isbn10", "isbn13" or both (for matching either type).

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be called directly.

Value

A logical vector that is TRUE when the input contains valid ISBN book codes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
x10 <- c(
  hyphens             = "0-387-98503-4",
  spaces              = "0 387 98503 4",
  just_numbers        = "0387985034",
  too_long            = "00-387-98503-4",
  too_short           = "0-387-9850-4",
  non_numeric         = "Z-387-98503-4",
  invalid_check_digit = "0-387-98503-5",
  missing             = NA
)
x13 <- c(
  hyphens             = "978-0-387-98503-9",
  spaces              = "978 0 387 98503 9",
  just_numbers        = "9780387985039",
  too_long            = "9978-0-387-98503-9",
  too_short           = "978-0-387-9850-9",
  non_numeric         = "Z78-0-387-9850-9",
  invalid_check_digit = "978-0-387-98503-8",
  missing             = NA
)
is_isbn_code(x10, type = "10")
assert_any_are_isbn_codes(x10, type = "10")
is_isbn_code(x13, type = "13")
assert_any_are_isbn_codes(x13, type = "13")
# These checks should fail.
assertive.base::dont_stop(assert_all_are_isbn_codes(x10, type = "10"))
assertive.base::dont_stop(assert_all_are_isbn_codes(x13, type = "13"))

assertive.data documentation built on May 2, 2019, 6:08 a.m.