Skip to content

Instantly share code, notes, and snippets.

@JohannesNE
Last active April 5, 2023 21:40
Show Gist options
  • Save JohannesNE/4a635f4dc7446271530c to your computer and use it in GitHub Desktop.
Save JohannesNE/4a635f4dc7446271530c to your computer and use it in GitHub Desktop.
Generate bibliography for R packages
#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