R: Basic Data Types

In Programming Language, we need to use variables to store information. Variables are used to store data of different types. As we know different data types requires a different size of memory space. We can perform some specific operations on these data types.

In R, Everything is an object. R has the following basic data types:

  1. Logical
  2. Numeric
  3. Integer
  4. Character
  5. Complex

1. Logical

In R Language, logical value is created by comparison between two or more variables.

Example:

x=2
y=3
z=x>y

print(z)
print(typeof(z))

Output:

[1] FALSE
[1] "logical"

2. Numeric

It is a data type that is used for numbers in R.

Example:

x=8.7
print(typeof(x))

Output: [1] "double"

3. Integer

It supports integer data types which are the set of all integers.

Example:

x=9L
print(typeof(x))

Output: [1] "integer"

4. Characters

It is a data type that supports all the alphabets and special characters. 

Example:

char="ProgramsBuzz"
print(typeof(char))

Output: [1] "character"

5. Complex

This data type support set of all the complex numbers.

Example:

x=4+3i
print(typeof(x))

Output: [1] "complex"