Last active
March 3, 2017 22:48
-
-
Save jsta/fe3da0dde410eb162cc974282b0d53a5 to your computer and use it in GitHub Desktop.
Extract doi from bibtex R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dt <- knitcitations::read.bibtex("foo.bib") | |
dt <- dt[grep("doi", tolower(dt)),] | |
res <- stringr::str_extract(dt, "(?=10)(.*?)(?<=\\s)") | |
res <- as.character(sapply(res, function(x) substring(x, 1, nchar(x) - 3))) | |
(res <- res[!is.na(res)]) | |
# paste0("http://dx.doi.org/", res) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment