Last active
April 5, 2023 21:40
-
-
Save JohannesNE/4a635f4dc7446271530c to your computer and use it in GitHub Desktop.
Generate bibliography for R packages
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
#Generate .bib for base R + loaded R packages. | |
pat <- "package:(.*)" | |
packages <- sub(pat, "\\1", grep(pat, search(), value = TRUE)) | |
cite_packages <- c("base", packages[-(which(packages == "stats"):length(packages))]) #Adds base R citation and removes base packages | |
capture.output( | |
for (i in cite_packages) print(citation(i), style = "Bibtex"), | |
file = "R_cite.bib") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment