top of page
Writer's pictureAnn Neo

R and RStudio : 5 Easy Steps to Download!

Updated: May 8, 2021

Run R programming easily on your system!

For Windows, Mac OS X, and Linux machines.


Run R in Windows

2. Navigate to the CRAN at the left sidebar

3. Select a CRAN mirror at a location close to you

4. Select “Download R for Windows”

5. Select the link for the base distribution

6. Run the downloaded .exe file and follow the default steps and instructions to install R, including confirming the installation, agreeing to the license, and choosing the file path


FAQ : Should I install the 32-bit version or the 64-bit version?

Note that the 64-bit version of R will not work on a 32-bit machine, but both the 32-bit and 64-bit versions will run seamlessly on 64-bit Windows. As such, it is recommended to install the 32-bit version if your production environment is 32-bit, because some packages might have compatibility issues.


Run R in macOS

2. Navigate to the CRAN at the left sidebar

3. Select a CRAN mirror at a location close to you

4. Select “Download R for (Mac) OS X”

5. Select the link for the base distribution

6. Run the downloaded installer file and follow the default steps and instructions to install R, including confirming the installation, agreeing to the license, and choosing the file path


Run R in Linux

Bear with me here, there are a few extra steps that you will need to follow!

The following steps are specifically for Ubuntu 18.04, but it should also work for other Debian-based Linux distributions.

The Advanced Packaging Tool (APT) that comes with Ubuntu uses a file called sources.list to decide on the location to search for packages. So, before you install R, you need to instruct Ubuntu to look into the CRAN R repositories and also add a public key for secure download.

1. Open the sources.list file (usually located at /etc/apt/sources.list) in a text editor, and add on the following line at the very end :

deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu <distribution>/

For instance, if you are running Ubuntu trusty and want to use the RStudio CRAN mirror, the line that you will need to add will be :

deb https://cran.rstudio.com/bin/linux/ubuntu trusty/

- Alternatively, you can do this step without using a text editor by typing the following directly in the terminal :

sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'

2. Authenticate the Ubuntu packages on CRAN The packages for Ubuntu that are stored on CRAN mirrors are all signed using a key with an ID, for example E084DAB8. You will need to download the public key from the Ubuntu keyserver using this ID, and then add it to our system. Use this command :

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB8

3. Update the list of available packages Since you modified the sources.list, you need to tell APT to download the packages that are available from the CRAN servers. Use this command :

sudo apt-get update

4. Download and install R Now, download and install the R package by running the command :

sudo apt-get -y install r-base

5. Open up the R console and issue this command :

$ R

If there were no issues during installation, your R console should open successfully with information about your R installation.


Now, you are all set to download RStudio!


Installing RStudio

RStudio is the most popular IDE for running R programs. And it has a free license!

Download RStudio (Windows, Linux, and Mac OS X), then run the downloaded installer file. Follow the default steps and instructions to install it, including confirming the installation, agreeing to the license, and choosing the file path.

Note that R should be installed in your system before you can run RStudio.


After you install RStudio and open it for the first time, it will prompt you to choose your R version.

If RStudio detects that R has yet to be installed in your system, a warning message will appear.

If R has been installed, you will then see the R Studio interface. You will likely only see the R console where you can write one line statements in R and then execute them.

However, even for trivial work, you will need to perform a sequence of steps, which is better executed in an R script.

Go to File > New File > R Script to create a new R script.

You can now see the R Script Editor where you can type and save R programs. As you will now understand, RStudio is not just a text editor, but an IDE that helps you easily run and debug R scripts!

Comments


Post: Blog2 Post
bottom of page