Created
October 15, 2019 13:00
-
-
Save philipperemy/0b6e803be085bd4101e3e2d66be38be1 to your computer and use it in GitHub Desktop.
R package manager (kind of) - Find and install all dependencies of your R project.
This file contains 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
set -e | |
PACKAGES="$(find . -type f -iname "*.R" -exec cat {} + | grep "^library" | sed 's/library(//g' | cut -d ')' -f 1 | sed -e 's/^"//' -e 's/"$//' | sort -u | xargs)" | |
for package in $PACKAGES; | |
do | |
echo "Installing package: ${package}..." | |
rscript -e "install.packages('${package}', repos='https://cran.rstudio.com')" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment