Skip to content

Instantly share code, notes, and snippets.

@agyemanjp
Last active December 14, 2023 14:19
Show Gist options
  • Save agyemanjp/af170790c3a49e40e3c56f32c2937366 to your computer and use it in GitHub Desktop.
Save agyemanjp/af170790c3a49e40e3c56f32c2937366 to your computer and use it in GitHub Desktop.
# See https://docs.posit.co/resources/install-r-source/
sudo apt install -y \
gfortran g++ \
curl libcurl4-openssl-dev \
libicu-dev \
libbz2-dev \
liblzma-dev \
libpcre2-dev \
libpcre3-dev &&\
# libpango1.0-dev \
export R_VERSION=4.1.2 &&\
curl -O https://cran.rstudio.com/src/base/R-4/R-${R_VERSION}.tar.gz &&\
tar -xzvf R-${R_VERSION}.tar.gz &&\
cd R-${R_VERSION} &&\
./configure \
--prefix=/opt/R/${R_VERSION} \
--enable-R-shlib \
--enable-memory-profiling \
--with-blas \
--with-lapack \
--with-readline=no \
--with-x=no &&\
make && sudo make install &&\
/opt/R/${R_VERSION}/bin/R --version &&\
sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R &&\
sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript
echo "$(lsb_release -si)_$(lsb_release -sr)" | tr ' ' '_'
base_url="https://hypothersize-deps-cache.s3.amazonaws.com/r_modules_"
lsb_info=$(echo "$(lsb_release -si)_$(lsb_release -sr)" | tr ' ' '_')
file_extension=".tar.gz"
new_url="${base_url}${lsb_info}${file_extension}"
echo "${'https://hypothersize-deps-cache.s3.amazonaws.com/r_modules_'}${lsb_info}${file_extension}"
folder="r_modules"
mkdir -p "$folder" &&\
echo "Downloading & extracting R packages ..." &&\
wget -qO- "$url" | tar -xz -C "$folder" --strip-components=1 &&\
# Checking if extraction was successful
if [ $? -eq 0 ]; then
echo "Download & extraction complete" &&\
echo "Extracted packages:" &&\
ls -alh r_modules
# echo "Done."
else
echo "Download & extraction failed." &&\
exit 1
fi &&\
psi www.hypothesize.io --key=$PSI_API_KEY --strategy=desktop --format=json | aws s3 cp - s3://hypothesize-dashboard-1/$(date +'%Y-%m-%d-%I-%M').psi.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment