normalize_issn {libbib}R Documentation

Attempt to enforce validity and canonical form to ISSN

Description

Takes a string representation of an ISSN. Strips all non-digit and non-"X" characters and checks if it is valid (whether the check digit works out, etc). User can specify whether "aggressive" measures should be taken to salvage the malformed ISSN string.

Usage

normalize_issn(x, aggressive = TRUE, pretty = FALSE)

Arguments

x

A string

aggressive

A logical indicating whether aggressive measures should be taken to try to get the "ISSN" into a valid form. See "Details" for more info (default is TRUE)

pretty

A logical indicating whether the ISSN should be prettily hyphenated (default is FALSE)

Details

If aggressive is TRUE, aggressive measures are taken to try to salvage the malformed ISSN string. If the ISSN, for example, is 7 digits, and either adding an "X" to the end, or leading "0"s fix it, this function will return the salvaged ISSN. If the ISSN has garbage digits/characters in the front and has an "X" check digit, it will return the salvaged ISSN.

Value

Returns valid ISSN if possible, NA if not

Examples


# adds leading zero
normalize_issn("3785955")                          # "03785955"

# adds X to 7 digit ISSN if valid
normalize_issn("2434561")                          # "2434561X"

normalize_issn("2434561", pretty=TRUE)             # "2434-561X"

# finds correct sequence
normalize_issn("21335212434561X")                  # "2434561X"

# vectorized
normalize_issn(c("__2434__561X", "2434561", "21335212434561X"))
# "2434561X" "2434561X" "2434561X"


[Package libbib version 1.6.4 Index]