<h5>Update 5 May 2021</h5>

With time as my knowledge improved, I learned that conda-forge is more reliable than installing from private repositories as it is tested and reviewed thoroughly by the Conda team. So here are new steps to install R.

Also r-studio available on the Anaconda package site downgrades the r-base from 4.0.3 to 3.6 version so I no longer suggest installing r-studio that way. In case if you want to use studio, just activate your R environment in conda and whichever r-base version is available in that environment, studio will pick it up. So same rstudio can run on multiple R versions by switching between different R environments in conda.

Also making a separate R environment is desirable to keep it safe from unintentional upgrade/downgrade of r-base (some tools come with their own r-base version and downgrades r-base).

Finally use mamba for quickly installing r packages and resolving dependencies issues.

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh 
&& chmod +x miniconda.sh && bash miniconda.sh -b -p miniconda

base_dir=$(echo $PWD)

export PATH=$base_dir/miniconda/bin:$PATH
source ~/.bashrc
echo -e "$base_dir/miniconda/etc/profile.d/conda.sh" >> ~/.profile
conda init bash

Installing R

# installing Mamba for fasta downloading of packages in conda
conda install mamba -n base -c conda-forge -y
conda update conda -y
conda update --all

# Creating R environment in conda
mamba create -n R -c conda-forge r-base -y
#Activating R environment
conda activate R
mamba install -c conda-forge r-essentials

# Open R and install BiocManager and select a mirror to install the packages from. Use the following 

if (!requireNamespace("BiocManager", quietly = TRUE))

Note: You can not update R-packages installed through r-essentials especially rcurl. So it is still not a very good way of installing R. Packages such as ComplexHeatMap packages and Cairo can not be installed.

Source link