Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
R package manager (kind of) - Find and install all dependencies of your R project.
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;
echo "Installing package: ${package}..."
rscript -e "install.packages('${package}', repos='')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.