A variable in a programming language is a memory space allocated to store values. You can use variables to store different types of values that include integer, character, factor, float, matrices, and tables. The scope of a variable defines the accessibility of the variable within a program. By default, variables are accessible from any part of the program. When the variable scope is given a constraint, it can be assessed within a function. Defining the scope of a variable helps avoid the collision of variables with the same name. Therefore, a variable is defined either global for accessing it from anywhere in the program or local that limits the access to the function where it is used.