R Installation

R Installation

  • R
  • 4 mins read

This article will take you through the basic installation steps required to set up R on different environments Windows, Linux, and macOS, and prepare the users to start programming in R!

About R

The R programming language, a multi-faceted tool, gained popularity due to its platform independence. It can be easily set up in various environments; Linux, Ubuntu, as well as MacOS. The portability across environments is also swift and simple. 

Beginning with R would require setting up an environment comprising of the language, R, as well as an IDE to execute the code from. A large number of software applications are available to learn and enhance R programming skills, some of which are Rattle, R Studio, Visual Studio, or StatET. R Studio is the most popular among these, which is used to carry out debugging, visualizations as well as analysis. 

Installation of R

The development of R is maintained by the Comprehensive R Archive Network. R can be downloaded from https://cran.r-project.org/bin/ for all types of environments.

R Installation in Windows

The R support for Windows can be downloaded from the link https://cran.r-project.org/bin/windows/base/ Upon opening the URL, click the hyperlink showing “Download R-v for Windows”. Here, v is the currently available version of R.

An executable installer program with the extension .exe will be downloaded, which needs to be installed and launched for further usage. Upon completion of the installation instructions, the user is prompted to “Launch R”. R will be downloaded in the program files directory.

A new script can be created by clicking on the File option, followed by clicking the “New Script”. Any basic program can now be executed by simply printing a numerical or string value onto the console. The output can be visualized by clicking the “Run line or selection” wherein the console opens to display the desired output.

R Installation in MacOS

The R language can be downloaded for the MacOS systems by simply clicking on the link https://cran.r-project.org/bin/macosx/base/ available on CRAN. The .pkg extension installer program will be downloaded.

The installation steps need to be followed to launch R. The user will also be prompted to input the password to complete the installation.

Upon successful download, R will be available in the local directory system and can be simply accessed from the terminal.

Open the MAC terminal and simply write R on it. This will start scripting in R. Any simple program can be executed now. In the following screenshot, print 2 was input, which produced 2 as the output of the script.

R Installation in Linux 

Most Linux systems already come pre-installed with R, which can be checked by typing R on the command line. If R is present, it will show the current version of R installed on the system. If R is not present already, it can be downloaded from the CRAN website https://cran.r-project.org/bin/linux/, depending on the type of Linux operating system, Ubuntu or Debian. R programs can then simply be executed from the terminal by typing R and validated by printing basic lines on the console using the print command.

Using R

R language programs can directly be executed on MAC as well Linux terminals, by simply inputting the command 

R

In Windows systems, the shortcut of the installer created can be used to execute R scripts and display the results. 

However, running R programs on the command interface is not the preferable way of running R codes. It may work for the execution of basic R snippets. But, complex R programs require the integration of packages and libraries in order to produce analysis and visualizations. Multiple utilities are integrated as a single unit in the IDE that is available in any programming language. This not only avoids the hassle of setting up all the prerequisites manually but also improves the user experience and understanding of data properly. 

A large number of editors are available for R, namely, Visual Studio, R Studio, or STATet. R Studio is the most popular one, since, it is open source in nature.