Get Familiar with the Basics of R
This article tells readers how to get their systems ready for R—how to install it and how to use a few basic commands.
Ris an open source programming language and environment for data analysis and visualisation, and is widely used by statisticians and analysts. It is a GNU package written mostly in C, Fortran and R itself.
Installing R is very easy. Navigate the browser to www.rproject.org and click on CRAN in the Download section (Figure 1).
This will open the CRAN mirrors. Select the appropriate mirror and it will take you to the Download section, as shown in Figure 2.
Grab the version which is appropriate for your system and install R. After the installation, you can see the R icon on the menu/desktop, as seen in Figure 3.
You can start using R by double-clicking on the icon, but there is a better way available. You can install the R Studio, which is an IDE (integrated development environment)— this makes things very easy. It’s a free and open source integrated environment for R.
Download R Studio from https://www.rstudio.com/ products/rstudio/. Use the open source edition, which is free to use. Once installed, open R Studio by double-clicking on its icon, which will look like what’s shown in Figure 4.
The default screen of R Studio is divided into three sections, as shown in Figure 5. The section marked ‘1’ is the main console window where we will execute the R commands. Section 2 shows the environment and history. The former will show all the available variables for the console and their values, while ‘history’ stores all the commands’ history. Section 3 shows the file explorer, help viewer and the tab for visualisation.
Clicking on the Packages tab in Section 3 will list all the packages available in R Studio, as shown in Figure 6.
Using R is very straightforward. On the console area, type ‘2 + 2’ and you will get ‘4’ as the output. Refer to Figure 7.
The R console supports all the basic math operations; so one can think of it as a calculator. You can try to do more calculations on the console.
Creating a variable is very straightforward too. To assign ‘2’ to variable ‘x’, use the following different ways:
> x <- 2
> assign(“x”,2) OR
> x <- y <- 2
One can see that there is no concept of data type declaration. The data type is assumed according to the value assigned to the variable.
As we assign the value, we can also see the Environment panel display the variable and value, as shown in Figure 8. A rm command is used to remove the variable. R supports basic data types to find the type of data in variable use class functions, as shown below:
> x <- 2
> class(x)  “numeric”
The four major data types in R are numeric, character,
Figure 1: R Project website
Figure 2: R Project download page