Description Usage Arguments Related Functions and Methods Note See Also Examples
S3 record class for DOIs.
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, ...)
|
prefix |
The naming authority. |
suffix |
The unique string chosen by the registrant. |
x |
A vector created by, or convertable to |
... |
Additional arguments passed to the S3 method. Currently ignored,
except two optional arguments |
protocol |
Logical flag, whether to prepend |
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. |
is_doi
: Is this a biblids_doi
?
is_doi_ish
: Could this be converted to a biblids_doi
using as_doi()
?
as_doi
: Normalise
biblids_doi
class (by generic):format
: Display a DOI
pillar_shaft
: Print DOIs in tibble::tibble()
s
knit_print
: Print DOIs in R markdown (when knitr is available):
DOIs are hyperlined to the doi.org resolution service.
library(knitr) # defaults to crossref style (recommended) doi_examples(na.rm = FALSE)[1:3]
# or use doi style knitr::knit_print(doi_examples(na.rm = FALSE)[1:3], display = "doi")
You can also include DOIs inline with https://doi.org/10.1038/nphys1170, https://doi.org/10.1007/978-3-642-65840-2_5 and https://doi.org/10.1594/PANGAE.726855.
is.na
: Detect if prefix
and/or suffix
is missing
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()
.
Other doi:
doiEntry
,
doi_api
,
doi_examples()
,
doi_ra
,
regex_doi()
,
view_doi_matches()
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.