Created
January 8, 2013 09:56
-
-
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.
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
############### | |
# 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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need to update this so that
LoadandCite
will only install packages that are not currently installed.