i

R Programming Complete Tutorial

R Syntax

Programming start-up

This chapter will explain all the important concepts of R programming. It will help us to understand the R programming syntax in detail.

R Syntax

R is an interpreted language, so it executes all the typed commands without requiring building the complete program.The syntax of this language is very simple; it mainly contains variables, operators, R functions, comments, and optionally library.

A variable provides us with named storage that our programmer can manipulate. To create a variable, we have to use a meaningful name and assign value either using a directional or equal operator. For example, a variable can be declared by using both ways.

An operator is a symbol that tells the computer to perform specific mathematical or logical manipulations. R-language is rich in built-in operators and provides Arithmetic, Relational, Logical, and assignment operations. In the example, we use the summation operator.

In R, a function is an object, so the R-interpreter can pass control to the function, along with arguments that may be necessary for the function to accomplish the actions. In our example, we have used the built-in print function that will display the result. 

Comments are like helping text in R, and they are ignored by the interpreter while executing the program. We can use a hash (#) symbol at the beginning of the comment statement.

And finally, the libraries. In some cases, we need special packages to perform specific tasks. We are already aware of ggplot2, which is used for graphics, or dplyr is used for data analysis. We may need to use libraries as per our requirements.