Data types are an integral part of any programming language. They are one of the pioneer building blocks and the development of any programming language usually revolves around them. Consider data types as the oxygen of any programming language. Important for their existence. The same is the case with R Programming.
The fundamental/atomic data types in R programming are as follows:
Numeric Data Type
If we assign any decimal value to a variable it becomes a variable of a numeric data type
> x <- 45.6 > class(x)  "numeric"
Integer Data Type
To create an integer variable in R, we need to call the (as.Integer) function while assigning value to a variable.
> e <- as.integer(3) > class(e)  "integer"
Another way of creating an integer variable is by using the L keyword as follows:
> x <- 5L > class(x)  "integer"
Complex Data Type
R also supports a complex data type under its environment.
A complex number is a combination that can be expressed in terms of a + bi where bi is the imaginary part and a, b are the real numbers.
> x <- 2 + 3i > class(x)  "complex"
Character Data Type
This data type is used to represent strings.
> x <- "Hello World" > class(x)  "character"
We can also use the as.character() function to convert objects into character values.
> x < as.charater(10.11) > print(x)  "10.11" > class(x)  "character"
Logical Data Type
A logical data type stores either of the two values: TRUE -/FALSE. A logical value is often generated when two values are compared.
> x <- TRUE > y <- FALSE > class(x)  "logical" > print(x & y) // Logical AND operation of TRUE and FALSE is FALSE  FALSE
We have covered the basic syntax to writing a program in R, along with learning what a variable is and how to define a variable we also discussed how to store data with different data types in r programming
This brings the end of this Blog. We really appreciate your time.
Hope you liked it.
Do visit our page www.zigya.com/blog for more informative blogs on Data Science
Keep Reading! Cheers!