Skip to content

Instantly share code, notes, and snippets.

@sklppr
Last active May 16, 2019 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sklppr/cec1b80642e02a12d4e57bc51d803c2e to your computer and use it in GitHub Desktop.
Save sklppr/cec1b80642e02a12d4e57bc51d803c2e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Install a custom R version, https://www.r-project.org/
#
# Add at least the following environment variables to your project configuration
# (otherwise the defaults below will be used).
# * R_VERSION
#
# Include in your builds via
# source /dev/stdin <<< "$(curl -sSL https://gist.githubusercontent.com/sklppr/cec1b80642e02a12d4e57bc51d803c2e/raw/089ca9b56d6b2364df29db4e78039c3404ce437f/r.sh)"
R_VERSION=${R_VERSION:="3.3.0"}
R_PATH=${R_PATH:=$HOME/r}
CACHED_DOWNLOAD="${HOME}/cache/R-${R_VERSION}.tar.gz"
mkdir -p "${R_PATH}"
wget --continue --output-document "${CACHED_DOWNLOAD}" "https://cran.r-project.org/src/base/R-${R_VERSION%%.*}/R-${R_VERSION}.tar.gz"
tar -xaf "${CACHED_DOWNLOAD}" --strip-components=1 --directory "${R_PATH}"
(
cd "${R_PATH}" || exit 1
./configure --enable-R-shlib
make
)
export PATH="${R_PATH}/bin:${PATH}"
# check the correct version is yused
R --version | grep "${R_VERSION}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment