Description Usage Arguments Value Note References Examples
Checks that the input contains Chemical Abstract Service registry numbers.
1 2 3 4 5 6 7 | assert_all_are_cas_numbers(x, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
assert_any_are_cas_numbers(x, na_ignore = FALSE,
severity = getOption("assertive.severity", "stop"))
is_cas_number(x)
|
x |
Input to check. |
na_ignore |
A logical value. If |
severity |
How severe should the consequences of the assertion be?
Either |
A logical vector that is TRUE
when the input contains valid
CAS registry numbers.
CAS numbers take the form of 1 to 7 digits followed by a hyphen, followed by 2 digits, another hyphen and a final check digit.
Chemspider (https://www.chemspider.com) is a good service for looking up CAS numbers.
1 2 3 4 5 6 7 8 9 10 11 12 13 | x <- c(
water = "7732-18-5",
d_glucose = "50-99-7",
l_glucose = "921-60-8",
no_hyphens = "7732185",
two_check_digits = "7732-18-55",
bad_check_digit = "7732-18-4",
missing = NA
)
is_cas_number(x)
assert_any_are_cas_numbers(x)
#These examples should fail.
assertive.base::dont_stop(assert_all_are_cas_numbers(x))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.