top of page

Variable Declaration And Objects

You're currently learning a lecture from the course: 


Prerequisite Terminologies

In order to have thorough understanding of the main topic, you should have the basic concept of the following terms:

Atomic Vector




Hamsa Ehsan


A variable is something that allows us to store data in it, which can be manipulated. A variable in R can store an atomic vector, group of atomic vectors or a combination of many R-objects. Variable’s name in R can consist of letters, numbers and the dot or underline characters. The variable’s name can’t start with a number.


  • Open RStudio.

  • To declare a variable, assign any value (Integer, character, float) to the variable using smaller than ‘<’ operator and a hyphen ‘-’:

       Variable_Name <- value

  • Assignment of the variable could be either leftward or rightward.

  • Leftward is what is shown above and the rightward is given below:

       Value -> Variable_Name

  • Once you declare a variable, the result can be seen in ‘Environment’ window.

  • You can see the result by just typing the variable name and press ‘Enter’, results would be shown just below your code in the ‘Console’.

  • You can also use Mathematical Operator on variables; simply use the operators with variables and see the result down below your code in the ‘Console’.


In this video, we got to see how we can declare variables in R; which allows Python shell like structure.

We also talked about the mathematical operator that can be applied on the variables.

File(s) Section

If a particular file is required for this video, and was discussed in the lecture, you can download it by clicking the button below.

bottom of page