R – type of
To get type of a value or variable or object in R programming, call typeof() function and pass the value/variable to it.
In this tutorial, we will learn how to use typeof() function to find the type of a value, with examples.
The syntax to use typeof() function to get the data type of variable
The function returns a character string.
The following are some of the possible values that typeof() function return.
In the following program, we will initialize a variable
x with a value of
2.8, and find its type using typeof() function.
x <- 2.8 typeof(x)
Now, let us assign
TRUE, and find the type of x programmatically.
x <- TRUE typeof(x)
In this R Tutorial, we learned how to get the type of an object, using typeof() function, with the help of examples.