Skip to content

Instantly share code, notes, and snippets.

@christophergandrud
Created January 8, 2013 09:56
Show Gist options
  • Save christophergandrud/4482567 to your computer and use it in GitHub Desktop.
Save christophergandrud/4482567 to your computer and use it in GitHub Desktop.
LoadandCite: a function for installing, loading, and creating a BibTeX bibliography of R packages.
###############
# LoadandCite: a function for installing, loading, and creating a BibTeX bibliography of R packages.
# Christopher Gandrud
# 9 January 2013
##############
# This function is partially based on: https://gist.github.com/3710171
LoadandCite <- function(packages, file = "", install = FALSE)
{
doInstall <- install
if(doInstall){install.packages(packages, repos = "http://cran.us.r-project.org")}
lapply(packages, library, character.only = TRUE)
knitr::write_bib(packages, file = file)
}
@christophergandrud
Copy link
Author

I need to update this so that LoadandCite will only install packages that are not currently installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment