You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be nice if we could add a DOI badge to our R packages, especially if they are published somewhere or citable using zenodo.
For example for https://zenodo.org/record/4692672 (my mdftracks package), this would be the badge: (if for some reason this won't load, please click the zenodo link, they also show the badge)
I have written a function that will add this badge:
extract_doi<-function(x) {
# pattern from https://www.crossref.org/blog/dois-and-matching-regular-expressions/pattern<-".*(10\\.\\d{4,9}/[-._;()/:A-Z0-9]+)$"if(!grepl(pattern, x, ignore.case=T, perl=T)) stop(glue("{x} is not a valid doi"))
gsub(pattern, "\\1", x, ignore.case=T, perl=T)
}
use_doi_badge<-function(doi) {
doi<- extract_doi(doi)
src<- glue("https://zenodo.org/badge/DOI/{doi}.svg")
href<- glue("https://doi.org/{doi}")
use_badge("DOI", href, src)
invisible(TRUE)
}
It accepts "naked" DOIs such as "10.5281/zenodo.4725473", or DOI links such as "https://doi.org/10.5281/zenodo.4725473"
Let me know if this would be useful, then I'll write some tests for the extract_doi function and prepare a pull request.
The text was updated successfully, but these errors were encountered:
Would be nice if we could add a DOI badge to our R packages, especially if they are published somewhere or citable using zenodo.
For example for https://zenodo.org/record/4692672 (my mdftracks package), this would be the badge:
(if for some reason this won't load, please click the zenodo link, they also show the badge)
I have written a function that will add this badge:
It accepts "naked" DOIs such as "10.5281/zenodo.4725473", or DOI links such as "https://doi.org/10.5281/zenodo.4725473"
Let me know if this would be useful, then I'll write some tests for the
extract_doi
function and prepare a pull request.The text was updated successfully, but these errors were encountered: