Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnjosephhorton/20f80084cec5692d88be5f54fc85b085 to your computer and use it in GitHub Desktop.
Save johnjosephhorton/20f80084cec5692d88be5f54fc85b085 to your computer and use it in GitHub Desktop.
Lazy way to get all the packges you use & then install them at once
# Find all your R files & get just the package names, uniquely
find ../analysis/ -name *R -print0 | xargs -0 grep -h 'library*' | sed 's/library//g' | sed 's/#//g' | sed 's/ //g' | sort | uniq|\
sed 's/(//g' | sed 's/)//g' > package_list.txt
# Install each package
cat package_list.txt | xargs -I {} Rscript -e 'install.packages("{}")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment