Skip to content

Instantly share code, notes, and snippets.

@dereckmezquita
Created November 25, 2022 15:35
Show Gist options
  • Save dereckmezquita/857ecb79c9623a898a962e859b544f6f to your computer and use it in GitHub Desktop.
Save dereckmezquita/857ecb79c9623a898a962e859b544f6f to your computer and use it in GitHub Desktop.
Replaces RStudio's buttons for building and installing an R package during development.
#!/usr/bin/env bash
# if $1 does not match either check or install
if [[ $1 != "check" ]] && [[ $1 != "install" ]] && [[ $1 != "check-install" ]]; then
echo "Usage: package-management.sh [check|install|check-install]"
fi
if [[ $1 == "check" ]]; then
Rscript -e "devtools::check()"
fi
if [[ $1 == "install" ]]; then
# get name of current directory
PROJECT_DIR=$(pwd)
PKGNAME=$(basename $(pwd))
cd ..
R CMD build $PKGNAME
R CMD INSTALL --no-multiarch --with-keep.source $PKGNAME
cd $PROJECT_DIR
fi
if [[ $1 == "check-install" ]]; then
Rscript -e "devtools::check()"
# get name of current directory
PROJECT_DIR=$(pwd)
PKGNAME=$(basename $(pwd))
cd ..
R CMD build $PKGNAME
R CMD INSTALL --no-multiarch --with-keep.source $PKGNAME
cd $PROJECT_DIR
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment