DEV Community

Cover image for Data Science 101: Install miniconda and rstudio on a Mac
Guille Acosta
Guille Acosta

Posted on

Data Science 101: Install miniconda and rstudio on a Mac

So, you want to start your Data Science journey to become a Quant developer but you have a Mac and you're not sure how to configure your environment to install miniconda and rstudio? Stay tuned, this is your post.

Step 1: install Xcode Developer Tools by running sudo xcode-select --install (you need at least Xcode 11.4)

Step 2: download and install rstudio from its website but do not open it yet.

Step 3: donwload miniconda from its website and follow the wizard steps.

with miniconda installed now you have a new command to use: conda. The idea behind conda is to create isolated environments where you can install not only different pypi libraries (as venv or virtualenv does on Python) but also install different versions of Python (or R, etc). This way you can create a conda env with python 2.9 and other conda env with python 3.10 on it.

Now it's time to open the Terminal to create a new conda env for R but first, to get the latest version we need to set the right channel.

conda config --add channels conda-forge

then you need to set the priority level as follows:

conda config --set channel_priority strict

Note: to undo this changes you can check these answers

At the time I'm writing this post default channel does not have R version >= 4.0 you can check it by running conda search r-base

Now you are good to create a new env like this:

conda create -n r-env r -y

this way you are creating a conda env called r-env which by default got latest r installed and -y flag to accept the terms.

to activate this env you should run:

conda activate r-env

once you finish your job you can deactivate it by doing:
conda deactivate
and if you want to delete this env you can do it this way:
conda env remove -n r-env

Now you are good to open rstudio and start working from there.

Happy coding!

PS: if you are running R on a M1 Mac, check this page for more information.

Top comments (0)