Find Data Type of an Object in R

To find the data type of an object you have to use class() function. The syntax for doing that is you need to pass the object as an argument to the function class() to find the data type of an object.

Syntax  

class(object)

Example 

R




# A simple R program
# to find data type of an object
 
# Logical
print(class(TRUE))
 
# Integer
print(class(3L))
 
# Numeric
print(class(10.5))
 
# Complex
print(class(1+2i))
 
# Character
print(class("12-04-2020"))


Output

[1] "logical"
[1] "integer"
[1] "numeric"
[1] "complex"
[1] "character"

R Data Types

Different forms of data that can be saved and manipulated are defined and categorized using data types in computer languages, including R. Each R data type has unique properties and associated operations.

Similar Reads

What are R Data types?

R Data types are used to specify the kind of data that can be stored in a variable....

Data Types in R Programming Language

...

Find Data Type of an Object in R

Each variable in R has an associated data type. Each R-Data Type requires different amounts of memory and has some specific operations which can be performed over it....

Type verification

...

Coerce or Convert the Data Type of an Object to Another

...