In this tutorial you will learn about the R Constants and its application with practical example.
R Constants
Constants refers to immutable values. Constants are basically literals whose values cannot be modified or changed during the execution of program. In R, constants can be of following types –
Numeric constants
It includes all the numeric data types including integer, double, complex. All the numeric constants followed by L are considered as integers and those followed by i are regarded as complex. The constants with 0x or 0X are considered as hexadecimal.
Example:-
1 2 3 4 5 6 |
> typeof(5) [1] "double" > typeof(5L) [1] "integer" > typeof(5i) [1] "complex" |
1 2 3 4 |
> 0xff [1] 255 > 0XF + 1 [1] 16 |
Character constants
Character constants are defined with pair of single (‘ ‘) or double quotes (” “).
Example:-
1 2 3 4 |
> 'example' [1] "example" > typeof("5") [1] "character" |