doi: Digital Object Identifiers

Description Usage Arguments Related Functions and Methods Note See Also Examples

View source: R/doi.R

Description

S3 record class for DOIs.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
doi(prefix = character(), suffix = character())

is_doi(x)

is_doi_ish(x)

as_doi(x, ...)

## S3 method for class 'biblids_doi'
format(x, ..., protocol = FALSE)

## S3 method for class 'biblids_doi'
pillar_shaft(x, ...)

## S3 method for class 'biblids_doi'
knit_print(
  x,
  display = getOption("biblids.doi_display", default = "crossref"),
  inline = FALSE,
  ...
)

## S3 method for class 'biblids_doi'
is.na(x, ...)

Arguments

prefix

The naming authority.

suffix

The unique string chosen by the registrant.

x

A vector created by, or convertable to doi().

...

Additional arguments passed to the S3 method. Currently ignored, except two optional arguments options and inline; see the references below.

protocol

Logical flag, whether to prepend doi: handle protocol, as per the official DOI Handbook.

display

character scaling, giving how to display a DOI. Must be one of:

inline

Logical flag, giving whether to render DOIs as a chunk output or inline R. Usually set by knitr.

Related Functions and Methods

Functions

Methods extending biblids_doi class (by generic):

Note

DOIs are returned as an S3 record class constructed by vctrs::new_rcrd(). Under the hood, these records are implemented as lists of fields (here: prefix, suffix). Support for such records may still be limited. For example, purrr::map() will erroneously loop over the fields, instead of over the DOIs (see #51). To avoid such problems, cast the DOI to a simple character vector using as.character().

See Also

Other doi: doiEntry, doi_api, doi_examples(), doi_ra, regex_doi(), view_doi_matches()

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
28
29
30
31
32
# this is the hard way to enter
doi(
  prefix = c("10.1038", "10.1000", "10.1007"),
  suffix = c("nphys1170", NA, "978-3-642-65840-2_5")
)
# DOIs are case insensitive and are compared as such
unique(as_doi(c("10.1000/foo", "10.1000/fOo")))
as_doi("10.1000/BAR") == as_doi("10.1000/bar")

# convert back to a (normalised) character
as.character(as_doi("10.1000/zap"))

is_doi(as_doi("10.1000/1"))
is_doi(1L)
as_doi(c(
  # example DOIs are from https://www.doi.org/demos.html
  "10.1594/PANGAE.726855",
  " 10.1594/GFZ.GEOFON.gfz2009kciu ",  # leading/trailing spaces are removed
  "https://doi.org/10.1000/182",  # URL form is parsed
  "doi:10.1000/7",  # DOI from is parsed
  "foo bar",  # returns NA
  NA_character_  # returns NA
))
## Not run: 
# there must be only one DOI per element
as_doi(c("10.1126/science.169.3946.635 10.6084/m9.figshare.97218"))

## End(Not run)
# there is extra pretty printing inside tibbles
tibble::tibble(c(doi_examples(na.rm = FALSE)[1:3]))
# this can be constructed but will be NA
is.na(doi(prefix = "10.1000", suffix = NA))

subugoe/biblids documentation built on Dec. 11, 2021, 6:55 a.m.