Installing R-devel along side with R-release on linux

(Taken from somewhere on stack overflow and modified)

# 1. You might need to do this first

sudo apt-get build-dep r-base
sudo apt-get install xorg-dev

# 2. Set up environmental variables so that we do not need to repeat the names of directories: A directory for the sources and a directory for the compiled distro.

export RDEVEL=/usr/local/lib/R-devel
sudo mkdir -p $RDEVEL ## A system directory; hence sudo

export RSOURCES=~/src
mkdir -p $RSOURCES

## export LBIN=~/local/bin
## mkdir -p $LBIN   

# 3. Get the sources + recommended packages:

cd $RSOURCES
svn co https://svn.r-project.org/R/trunk R-devel 
R-devel/tools/rsync-recommended

# 4. Build R and packages:

cd $RDEVEL
sudo $RSOURCES/R-devel/configure && sudo make -j

# 5. Remove $RSOURCES directory

rm -rf $RSOURCES

# 6. Save the following script in the file Rdev in e.g. ~/local/bin (Assuming $RDEVEL is set as above; otherwise modify R_LIBS_SITE below)

#!/bin/bash
export R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R-devel/lib/R/library:~/R/x86_64-pc-linux-gnu-library/4.3'}
export PATH="/usr/local/lib/R-devel/bin/:$PATH"
# echo $PATH
# echo `whereis R`
R "$@"

# 7. Make the script executable with

chmod a+x ~/local/bin/Rdev

# 8. Add ~/local/bin to the PATH, e.g. by adding the following line to .bashrc

PATH="$PATH:~/local/bin"

# Notice: In short form: Steps 2.-5.:

export RDEVEL=/usr/local/lib/R-devel
sudo mkdir -p $RDEVEL ## A system directory; hence sudo

export RSOURCES=~/src
mkdir -p $RSOURCES

cd $RSOURCES
svn co https://svn.r-project.org/R/trunk R-devel 
R-devel/tools/rsync-recommended

cd $RDEVEL
sudo $RSOURCES/R-devel/configure && sudo make -j
       
rm -rf $RSOURCES

# Notice: Steps 6 and 7: just paste the following into a terminal:

cat <<EOF>~/local/bin/Rdev;
#!/bin/bash
export R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R-devel/lib/R/library:~/R/x86_64-pc-linux-gnu-library/4.3'}
export PATH="/usr/local/lib/R-devel/bin/:$PATH"
# echo $PATH
# echo `whereis R`
R "\$@"
EOF
chmod a+x ~/local/bin/Rdev