How to Install R Studio on Windows and Linux?

R programming language is a language and free software environment, available under GNU license, supported by R Foundation for Statistical Computing. The language is most widely known for its powerful statistical and data interpretation capabilities.
To use R language, you need the R environment to be installed on your machine, and an IDE (Integrated development environment) to run the language (can also be run using CMD on Windows or Terminal on Linux).
So, the question remains, as to why and how to install R Studio on Windows and Linux.
Why to use R Studio?

  • It is a powerful IDE, specifically used for R language.
  • Provides literate programming tools, which basically allows use of R scripts, outputs, text and images into report, Word document and even an HTML file.
  • Use of Shiny (open source R package) allows us to create interactive content in reports and presentations.

Installing R Studio on Windows

Step 1: First, you need to set up R environment in your local machine. You can download the same from r-project.org.

Step 2: After downloading R for Windows platform, install it by double-clicking it.

Installing R for Windows platform.

Step 3: Download R Studio from R Studio (Desktop) downloads page. Note: It is free of cost (under AGPL licensing).
Downloading R Studio for Windows.

Step 4: After downloading, you will get a file named “RStudio-1.x.xxxx.exe” in your Downloads folder.



Step 5: Double-click the installer, and install the software.

Step 6: Test the R Studio installation

  • Search for RStudio in Window search bar on Taskbar.
  • Start the application.
  • Insert the following code in console.
    Input  : print('Hello world!') 
    Output : [1] "Hello world!"
    

    R console on Windows.

Step 7: Your installation is successful.

Installing R Studio on Ubuntu

Installing R Studio on Ubuntu has steps similar to Windows:

Step 1: Installing the R environment on Ubuntu.

  • Through Terminal
    • Step 1: Open terminal (Ctrl+Alt+T) in Ubuntu.
    • Step 2: Update the packages cache.
      sudo apt-get update
    • Step 3: Install R environemnt.
      sudo apt -y install r-base

      Check for version of R package using

      R --version
    • Step 4: Check R installation by using following command.
      user@Ubuntu:~$ R 

      (Note that R version should be 3.6+ to be able to install all packages like tm, e1071, etc.). If there is issue with R version, see the end of the post.

    • Step5: Exit the terminal.

  • Through Ubuntu software Center
    • Step 1: Open Ubuntu Software center.
    • Step 2: Search for r-base.
    • Step 3: Click install.
    • Step 4: Check for R installation as above.

Step 2: Downloading R Studio on Ubuntu

  • Step 1: Install gdebi package to install .deb packages easily.
    sudo add-apt-repository universe
    sudo apt-get install gdebi-core
  • Step 2: Go to R Studio downloads page and select the latest *.deb package available under Ubuntu 18/Debian 10.
  • Step 3: Navigate to Downloads folder in local machine.
    $ cd Downloads/
    $ ls
     rstudio-1.2.5042-amd64.deb
    
  • Step 4: Install using gdebi package.
    sudo gdebi rstudio-1.2.5042-amd64.deb


  • Step 5: Run the RStudio using
    • Terminal
      user@Ubuntu:~/Downloads/ $ rstudio 
    • Alternatively, use menu to search for Rstudio.
  • Step 6: Test the R Studio using basic “Hello world!” command and exit.
    Input  : print('Hello world!') 
    Output : [1] "Hello world!"
    

Alternatively, RStudio can be installed through Ubuntu Software as well, but using above approach generally guarantees latest version is installed.

If there are issues with R version getting downloaded or previously installed version is older, check R version with

R --version

Now, Run the following commands in Terminal (Ctrl + Alt + T)

  • Add the key to secure APT from CRAN package list.
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
  • Add the latest CRAN repository to repository list. (This is for Ubuntu 18.04 specifically)
    sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
  • Update the package cache.
    sudo apt update
  • Install r-base package.
    sudo apt install r-base

Note: For further updates, latest keys and deb list for different Ubuntu versions can be found here.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.